Aşağıdaki kodlarda text nesnesindeki değerleri listeye içine eklemeyi öğreneceksiniz. Kodları kopyalayıp istediğiniz bir tarayıcıda çalıştırabilirsiniz.
Uygulama Çıktısı:
Uygulama Videosu:
Uygulama Kodları:
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 43 44 | <!DOCTYPE html> <html lang="tr"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>JavaScript Nesnes Oluşturma(Yazılım Kodlama)</title> <style> input{ padding:8px 30px; margin-right:10px; } button{ background: #5f27cd; color:#fff; border:none; padding:10px 30px; } </style> </head> <body> <input type="text" name="" id="urun"><button id="ekle">Ürün Ekle</button><br> <ul id="liste"> </ul> <script> const urun =document.querySelector("#urun"); const ekle =document.querySelector("#ekle"); const liste =document.querySelector("#liste"); ekle.onclick=function(){ let li=document.createElement("li"); li.textContent=urun.value; liste.appendChild(li); urun.value=""; urun.focus(); } </script> </body> </html> |