The Change Text wont change in the box to Have A nice day! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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>

7th May 2020, 7:25 PM
David
5 Answers
+ 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!";
7th May 2020, 7:31 PM
A͢J
A͢J - avatar
+ 1
it worked. thanks!
7th May 2020, 7:36 PM
David
+ 1
<br> use to make line break. For example: Have a <br> nice day nice day will print in the second line.
7th May 2020, 7:44 PM
A͢J
A͢J - avatar
+ 1
oh okay i see. thanks again!
7th May 2020, 7:46 PM
David
0
why did we have to add the <br> i am confused to as why it came to that. help
7th May 2020, 7:38 PM
David