Javascript: access DOM elements without getElementById [duplicate]

孤街浪徒 提交于 2019-11-29 16:09:05
Thad Blankenship

This answer should give you a lot to go on:

https://stackoverflow.com/a/6381766/944006

You shouldn't use these variables, and you DEFINITELY don't want to depend on them working correctly across browsers.

Backwards compatibility is the reason IDs are mapped to properties of the window.

It's also a major reason to avoid global variables - in fact some browsers will outright break if you try to use a global variable that's the same name as an element's ID.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!