Javascript Alert | Sololearn: Learn to code for FREE!
0

Javascript Alert

<!DOCTYPE html> <html> <body> <h2>JavaScript Numbers</h2> <input type="text" id="input" /> <button id="add" onclick="myfunction()">Concat</button> <script> function myfunction(){ var demo= document.getElementByID("input").value + "Demo"; document.write(demo); } </script> </body> </html> In above code m trying to take input in text field and write result on screen on pressing the button.Can anyone suggest what is wrong with code ?

10th Jul 2019, 1:39 PM
Nooruddin Raoti wala
Nooruddin Raoti wala - avatar
3 Respostas
+ 1
onclick="myfunction()"
10th Jul 2019, 2:51 PM
Gordon
Gordon - avatar
0
I also tried that still not happening
10th Jul 2019, 3:14 PM
Nooruddin Raoti wala
Nooruddin Raoti wala - avatar
0
Gordon's answer + these: getElementByID > getElementById document.write() > alert()
10th Jul 2019, 6:38 PM
khangnd
khangnd - avatar