Accessing DOM node by id
If you have DOM node with id like
<div id="foo"></div>
you can access it by referring to the variable named according to the id of DOM node:
alert(foo)
You can test it using Developer Tools in Chrome:
Written by Vasiliy Ermolovich
Related protips
3 Responses
Doesn't that mean ID-used words are reversed now (can't be used as variable names)?
over 1 year ago
·

Hey, you can read detailed explanation here http://stackoverflow.com/a/3434388/336626
over 1 year ago
·

too much magic, can be clobbered by variables named the same as an element ID
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Dom
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#