Why don't we just use element IDs as identifiers in JavaScript?
问题 All browsers I\'ve come to work with allow accessing an element with id=\"myDiv\" by simply writing: myDiv See here: http://jsfiddle.net/L91q54Lt/ Anyway, this method seems to be quite poorly documented, and in fact, the sources I come across don\'t even give it a mention and instead assume that one would use document.getElementById(\"myDiv\") or maybe document.querySelector(\"#myDiv\") to access a DOM element even when its ID is known in advance (i.e. not calculated at runtime). I can tell