MDN self-hosted library · e01.org

Element: childElementCount property

DOM

Open notebook · 1 cells web-api-instance-property upstream source

DOM

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

Examples

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

Specifications

Browser compatibility

See also

  • Document.childElementCount
  • DocumentFragment.childElementCount