Good morning sir. When i access p in script ans set it and run html file without Window.onload function. What happens?I get eror | Sololearn: Learn to code for FREE!

0

Good morning sir. When i access p in script ans set it and run html file without Window.onload function. What happens?I get eror

run script without window.onload https://code.sololearn.com/W70ybgu3J1Np/?ref=app

5/2/2022 7:59:10 AM

Malick Diagne

1 Answer

New Answer

+2

Malick Diagne if you don't use window.onload, you will get error because your javascript code is executing before the loading of your html file. Because of this there was no <p> tag was created. So your variable paragraph was NULL, that's why it shows error because document.getElementById( ) did not found any <p> tag in the html document