+ 6

What's wrong with This Code?

Hello World! I'm new to JavaScript & I Can't Understand What's Wrong With This Code. Someone Please Explain It... <!DOCTYPE html> <html> <head> <script> var name = prompt("What Is Your Name?"); document.getElementById("demo").innerHTML = name; </script> </head> <body> <p id="demo"></p> </body> </html>

14th Jun 2020, 3:39 PM
Noob Programmer
Noob Programmer - avatar
2 Respostas
+ 4
if you write your code in head the paragraf demo is not known. So works: <!DOCTYPE html> <html> <head> </head> <body> <p id="demo"></p> <script> var name = prompt("What Is Your Name?"); document.getElementById("demo").innerHTML = name; </script> </body> </html>
14th Jun 2020, 4:54 PM
JaScript
JaScript - avatar
+ 6
Yes Bro... I wanna print it as a paragraph... #bluesea
14th Jun 2020, 4:15 PM
Noob Programmer
Noob Programmer - avatar