HTML DOM lengthProperty

元素对象参考手册Element Object

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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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


元素对象参考手册Element Object

Other Extensions