DocumentFragment: firstElementChild property
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2018.
TheDocumentFragment.firstElementChild read-only propertyreturns the document fragment's first childElement, ornull if thereare no child elements.
In this article
Value
AnElement that is the first childElement of the object, ornull if there are none.
Examples
js
let fragment = new DocumentFragment();fragment.firstElementChild; // nulllet paragraph = document.createElement("p");fragment.appendChild(paragraph);fragment.firstElementChild; // <p>Specifications
| Specification |
|---|
| DOM> # ref-for-dom-parentnode-firstelementchild①> |