HTML DOM lengthProperty
Examples
Return the number of child nodes of the body element:
document.body.childNodes.length;
Output:
8
Try it Yourself »
Definition and Usage
The length property returns the number of nodes in a node list.
The child node collection of a node object is an instance of a NodeList object.
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the length property
Syntax
nodelist.length
Technical Details
| Return Value: | Returns a number representing the number of nodes in the node list. |
|---|---|
| DOM Version | Core Level 1 Nodelist Object |
Other Extensions
Element Object