+ 1
Can someone explain why this code works despite commenting out the getElement line.
I mistakenly forgot to get an element in my code and i used it id with the style method and it worked, it makes me curious. https://code.sololearn.com/WHrldXW435YF/#html
5 Réponses
+ 4
Because all elements which you assigned an id are accessible also with "window.element_id" or simply "element_id"
+ 4
Yussuf Toheeb Notice than though window.el_id works on many browser ITS NOT the proper way to handle the problem. Its an old way implemented in IE and used by other browsers also but the "official" way is use getElementById or querySelector functions
+ 4
👍👍👍
+ 2
Thanks
Is it now safe to use the method, I mean ID straight without getting them to a variable before using them?
+ 2
Now I got it clearer.
Thanks KROW, I appreciate it