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

View in English Always switch to English

DocumentFragment: firstElementChild プロパティ

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.firstElementChild; // null

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

fragment.firstElementChild; // <p>

仕様書

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

ブラウザーの互換性

関連情報