This is called named access
. Each element having an
id will be referenced in the global scope. This is a window object
. Although not recommended, it is standardized using HTML5
.
A simple conflicting case for using it is
If you declare a variable in the global scope, for example hide
, and also you have element
in document
with id
hide
. Then this element reference will be overridden by our global variable
. At that time, if you use it ( element
reference) in any event handler or somewhere, this will lead to an error.
source share