English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML DOM childElementCount Property

HTML DOM Element Object

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.

Syntax:

ParentElement.childElementCount
var len = document.querySelector("div").childElementCount;
Test and See‹/›

Browser Compatibility

All browsers fully support the childElementCount property:

Property
childElementCountYesYesYesYesYes

Technical Details

Return Value:A number representing the number of child elements of an element
DOM Version:DOM Level3

HTML DOM Element Object