0

So, I was coding in class when accidentally got to this point, when you set any ID in HTML5 a global variable is created at the same time, which can be used on the script aparently the same way we use getElementById().

for example:

<div id="identifier"></div>

can be accessed in the script like:

identifier.style.whatever

Can anyone explain me why I can't find any information about this? also, why isn't anyone using this when coding? is it bad to use this instead of getElementById?

Jota
  • 1
  • 1
  • 2
    https://stackoverflow.com/questions/3434278/do-dom-tree-elements-with-ids-become-global-variables – epascarello Oct 17 '17 at 15:13
  • https://stackoverflow.com/questions/26331906/what-is-the-difference-between-getelementbyid-and-simply-using-an-elements-id-a – epascarello Oct 17 '17 at 15:14

0 Answers0