<div id="myDiv"></div>
alert(myDiv); // alerts '[html HTMLDivElement]'
I don’t understand how this seems to work. I thought you must specify the div element’s id with getElementById();
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.