+ 1

Weird behavior of javascript or html

Strange behavior of top body or head or external script. https://code.sololearn.com/WM4PAFEmuBI5

8th Sep 2020, 4:12 PM
ASP
ASP - avatar
2 Réponses
+ 7
HTML script is loaded from beginning to end. When the JS codes are in <head> or beginning of <body>, the elements are not created yet, so the get elements function returns null.
8th Sep 2020, 4:14 PM
Gordon
Gordon - avatar
0
First load the body/document then load js to let the dom work properly. Use script as last tag inside body tag.
8th Sep 2020, 7:02 PM
Divya Mohan
Divya Mohan - avatar