Reputation: 23
How do I accesss the div the id 950 in the example below using javascript?
<ins>
<div>
<div>
<div id="950"></div>
</div>
</div>
</ins>
A simple getelementbyid doesn't work...
document.getElementById('950');
Upvotes: 1
Views: 61
Reputation: 32117
make sure you are calling document.getElementById('950');
after dom elements are created.
Try shifting your code at the bottom of the page!!
Upvotes: 1
Reputation: 522
The ID attribute should start with a letter. Perhapse that is what causing JS parser to return an error.
Upvotes: 1
Reputation:
"id" can't begin with a number. See this: http://www.w3.org/TR/html4/types.html#type-name
Everything else is ok.
Upvotes: 1
Reputation: 134177
getElementById
always returns the requested element, without regard nesting level. Something else must be going on here. For example, what is the purpose of the ins
tag in your example?
Upvotes: 2