Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM length Property

HTML DOM length Property

Element Object Reference Element object

Example

Return the number of child nodes of the body element:

document.body.childNodes.length;

Output result:

8

Try it »


Definition and Usage

The length property returns the number of nodes in a collection.

The child node collection of a node object is an instance of a node list object.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the length property.


Syntax

nodelist

.length

Technical Details

Return Value: Returns a number that represents the number of nodes in a node list.
DOM version Core Level 1 Nodelist Object

Element Object Reference Element object