Back to Content

Element: childElementCount property

files/en-us/web/api/element/childelementcount/index.md

latest447 B
Original Source

{{ APIRef("DOM") }}

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

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • {{domxref("Document.childElementCount")}}
  • {{domxref("DocumentFragment.childElementCount")}}