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 NodeList.

This property is read-only.

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.

Related Products