Can anybody help me with this code, please? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
26th Mar 2018, 12:34 PM
marcopl
marcopl - avatar
2 Answers
+ 6
in SoloLearn, the codes in JS section are merged with html as a single file in the top while executing. so if ur trying to access Dom elements in ur js code, then browser would do that before loading of html itself, which causes that error. hence we do any DOM related manipulation after the body of html is loaded
26th Mar 2018, 12:51 PM
Morpheus
Morpheus - avatar
+ 2
It worked! Thanks! Why is window.onload so important? I tried on notepad++ and the code run perfectly without it...
26th Mar 2018, 12:46 PM
marcopl
marcopl - avatar