Document: firstElementChild プロパティ

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

Document.firstElementChild は読み取り専用プロパティで、この文書の最初の子要素 (Element) を返します。子要素がなければ null を返します。

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

文書内の特定の要素における最初の子要素については、 Element.firstElementChild を参照してください。

Element オブジェクト、または null です。

js
document.firstElementChild;
// この文書の唯一の子でである、ルート <html> 要素を返す

仕様書

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

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
firstElementChild

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報