HTML Form nesneleri kullanarak basit alan ve çevre hesabı yapılıp, sonuç HTML nesnesi içinde gösterilmiştir.
Kod:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | <!doctype html> <html> <head> <title>Jquery Örnekleri</title> <meta charset="utf-8"> <style> label{ display: block; } </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script> </head> <body> <h1>Dikdörtgen Alan ve Çevre Hesaplama</h1> <h2 id="alan"></h2> <h2 id="cevre"></h2> <label for="uzunluk">Uzunluk: <input type="text" id="uzunluk"> </label> <label for="genislik">Genişlik: <input type="text" id="genislik"> </label> <button id="hesapla">Hesapla</button> <script> $("#hesapla").bind('click',function(){ var uzunluk=Number($("#uzunluk").val()); var genislik=Number($("#genislik").val()); $("#alan").html("Dikdörtgen Alanı:"+genislik*uzunluk); $("#cevre").html("Dikdörtgen Çevresi:"+2*(genislik+uzunluk)); }); </script> </body> </html> |
Çıktı:
Yorum Yap