0

[solved]Why can code_01 get property width,and code_02 can't ?

These script and jsfile are same code. When is jsfile of the 3files(html,css,js) read? https://code.sololearn.com/Wct92EwbeVWJ/?ref=app https://code.sololearn.com/Wp856UEfIxk6/?ref=app

26th Feb 2021, 8:46 AM
bill peteson
bill peteson - avatar
2 Réponses
+ 3
Sololearn places javascript file inside head tag , so in code1 the script is executed before html dom is loaded and so there is no element with id "test1" yet.
26th Feb 2021, 8:55 AM
Abhay
Abhay - avatar
+ 1
Thank you for Easy-to-understand explanation.And fast answer!
26th Feb 2021, 9:13 AM
bill peteson
bill peteson - avatar