<div id="myDiv"></div>
alert(myDiv); // alert开发者_开发百科s '[html HTMLDivElement]'
I don't understand how this seems to work. I thought you must specify the div element's id with getElementById();
It only works in some browsers.
Internet Explorer does add all id's to the window object, so that you can access them directly. Most other browsers doesn't.
精彩评论