+ 1

Why doesnt document.body work?

So upon playing around i noticed that although document.body is null, if i instead use documentElement my code works....why? https://code.sololearn.com/WgGffE44Pach/?ref=app

19th May 2020, 11:55 PM
Chad Williams
Chad Williams - avatar
2 Respuestas
+ 7
You just did a simple mistake: Wrong : window.onload = start(); Correct : window.onload = start; If you do this, both document.documentElement and document.body will work :))
20th May 2020, 12:50 AM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
+ 2
😶
20th May 2020, 2:03 AM
Chad Williams
Chad Williams - avatar