length (W3C DOM Core property)
| Version | Depr. | Static | Read-only |
|---|---|---|---|
| DOM1 | No | No | Yes |
| IE5.5+ | FF1.5+ | SA1.3+ | OP9+ |
|---|---|---|---|
| Full | Full | Full | Full |
Example
var nodes = document.documentElement.childNodes;
for(var i=0; i<nodes.length; i++)
{
//do something with nodes[i]
}
In the example above we're saving a reference to the documentElement childNodes collection, then using its length property to iterate through the members of the
collection.
Description
The number of items in a
collection (a NamedNodeMap or NodeList), or the number of characters in the string
value of a character data node (CDATASection, Comment or Text).
This property is readonly.
Compatibility
| Internet Explorer | Firefox | Safari | Opera | |||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 5.5 | 6.0 | 7.0 | 1.5 | 2.0 | 3.0 | 1.3 | 2.0 | 3.0 | 9.0 | 9.5 |
| Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full |
No known issues.
User-contributed notes
There are no comments yet.
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.




