Element: childElementCount property

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

Examples

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

Specifications

Specification
DOM Standard
# dom-parentnode-childelementcount

Browser compatibility

desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
childElementCount

See also