Why it doesn't work?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
26th Feb 2018, 8:54 PM
Sina
Sina - avatar
4 Answers
+ 7
little modified now its working <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <input type="text" id="text"> <button onclick="a()">Ok</button> <script> function a(){ var x= document.getElementById("text").value; alert("Welcome " + x) } </script> </body> </html>
26th Feb 2018, 8:59 PM
Sudarshan Rai
Sudarshan Rai - avatar
+ 3
Why my code is wrong??
26th Feb 2018, 9:00 PM
Sina
Sina - avatar
+ 2
at onClick is event where in script it runs as funnction and i afarid it dosent tale inline script
26th Feb 2018, 9:08 PM
Sudarshan Rai
Sudarshan Rai - avatar
0
Why can't we write document.getElementById("text").value; at the onclick??
26th Feb 2018, 9:01 PM
Sina
Sina - avatar