Element.childElementCount

The Element.childElementCount read-only property returns the number of child elements of this element.

Syntax

element.childElementCount;

Example

let sidebar = document.getElementById('sidebar');
if (sidebar.childElementCount > 0) {
  // Do something
}

Specifications

Specification
DOM
The definition of 'ParentNode.childElementCount' in that specification.

Browser compatibility

BCD tables only load in the browser

See also