0
The Change Text wont change in the box to Have A nice day!
<!DOCTYPE html> <html> <body> <h2> Using The id attribute in JavaScript</h2> <p>JavaScript can access an element with a specified id by using the getElementById() method:</p> <h1 id="myHeader">Hello World!</h1> <button onclick="displayResult()">Change text </button> <script> function displayResult() { document.getElementById("myHeader").innerHTML="Have a nice day!"; } </script> </body> </html>
5 Réponses
+ 5
David Because there is a line break after Have a nice.
Have a nice day should be one line.
It should be like this:
"Have a nice day!";
+ 1
it worked. thanks!
+ 1
<br> use to make line break. For example:
Have a <br> nice day
nice day will print in the second line.
+ 1
oh okay i see. thanks again!
0
why did we have to add the <br>
i am confused to as why it came to that. help