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

View in English Always switch to English

DocumentFragment: 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月.

DocumentFragment.firstElementChild は読み取り専用プロパティで、この文書フラグメントの最後の子要素を返します。子要素がなければ null を返します。

このオブジェクトの最後の子要素である Element です。存在しなければ null です。

js
let fragment = new DocumentFragment();
fragment.lastElementChild; // null

let paragraph = document.createElement("p");
fragment.appendChild(paragraph);

fragment.lastElementChild; // <p>

仕様書

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

ブラウザーの互換性

関連情報