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 do开发者_JS百科esn't work...
document.getElementById('950');
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?
"id" can't begin with a number. See this: http://www.w3.org/TR/html4/types.html#type-name
Everything else is ok.
The ID attribute should start with a letter. Perhapse that is what causing JS parser to return an error.
make sure you are calling document.getElementById('950');
after dom elements are created.
Try shifting your code at the bottom of the page!!
精彩评论