Web APIs
Element.firstElementChild
Return the first direct element child, ignoring text and comment nodes. Example console output: STRONG.
Formal Syntax & Structure
javascript syntaxjavascript
element.firstElementChildReturn Value
Element or null
First child element or null.
Working Example
Example Snippetjavascript
const root=document.createElement("div"); root.append("heading",document.createElement("strong")); console.log(root.firstElementChild.tagName);