このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

Document: lastElementChild プロパティ

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2018年4月⁩.

Document.lastElementChild は読み取り専用プロパティで、この文書の最後の子要素 (Element)、または子要素がない場合は null を返します。

HTML 文書では、これは通常唯一の子要素であるルート <html> 要素です。

文書内の固有の要素の最後の子要素については Element.lastElementChild を参照してください。

ルート <html> 要素です。

js
document.lastElementChild;
// 文書のただ一つの子であるルート <html> 要素を返す

仕様書

Specification
DOM
# ref-for-dom-parentnode-lastelementchild①

ブラウザーの互換性

関連情報