文件:lastElementChild 屬性

Baseline 已廣泛支援

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

Document.lastElementChild 只讀屬性返回文件的最後一個子 Element,如果沒有子元素則返回 null

對於 HTML 文件,這通常是唯一的子元素,即根 <html> 元素。

有關文件中特定元素的最後一個子元素,請參閱 Element.lastElementChild

<html> 元素。

示例

js
document.lastElementChild;
// returns the root <html> element, the only child of the document

規範

規範
DOM
# ref-for-dom-parentnode-lastelementchild①

瀏覽器相容性

另見