length (W3C DOM Core property)

Spec
Version Depr. Static Read-only
DOM1 No No Yes
Browser support (more…)
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.

Related Products