Element: childElementCount property
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
这篇文档对你有帮助吗?
谢谢你的反馈!