文件:childElementCount 屬性

Baseline 已廣泛支援

此功能已成熟,可跨多種裝置和瀏覽器版本工作。它自 ⁨2018 年 4 月⁩ 起已在所有瀏覽器中可用。

Document.childElementCount 只讀屬性返回文件子元素的數量。

要獲取特定元素的子元素數量,請參閱 Element.childElementCount

一個數字。

示例

js
document.children;
// HTMLCollection, usually containing an <html> element, the document's only child

document.childElementCount;
// 1

規範

規範
DOM
# dom-parentnode-childelementcount

瀏覽器相容性

另見