DEV Community

Discussion on: The 3 most common DOM selectors

Collapse
 
efpage profile image
Eckehard

Yes, it is a bit strange feature you should not rely on. There is a global variable for every ID - as long as it is not conflicting with something. In the example above, it is conflicting with a variable, there might be ohter names like classnames etc.. In any case you can access the ID with getElementById without those conflicts.