English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
childElementCountA read-only property that returns the number of child elements of the specified parent element.
The returned value includes the number of child element nodes, not the number of all child nodes (such as text and comment nodes).
The childElementCount property will return the number of child element nodeselement.children.length to get the same result.
UsechildrenThe property returns the number of any child elements of the specified parent element.
ParentElement.childElementCount
var len = document.querySelector("div").childElementCount;Test and See‹/›
All browsers fully support the childElementCount property:
Property | |||||
childElementCount | Yes | Yes | Yes | Yes | Yes |
Return Value: | A number representing the number of child elements of an element |
---|---|
DOM Version: | DOM Level3 |