Latest web development tutorials

HTML DOM length property

Elements Object Reference Element object

Examples

Back body element number of child nodes:

document.body.childNodes.length;

Output:

8

try it"

Definition and Usage

length property returns the number of nodes in the collection.

Child nodes of the node object is an instance of a node list object.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support length property


grammar

nodelist.length

technical details

return value: Returns the number that represents the number of nodes in the node list.
DOM version Core Level 1 Nodelist Object


Elements Object Reference Element object