DOM
Element.childElementCount 只读属性返回该元素的子元素数量。
示例
let sidebar = document.getElementById("sidebar");
if (sidebar.childElementCount > 0) {
// 做点什么
}
规范
浏览器兼容性
参见
- Document.childElementCount
- DocumentFragment.childElementCount
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
