文档: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①

浏览器兼容性

另见