MDN self-hosted library · e01.org

Node: firstChild property

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

html
<p id="para-01">
  <span>First span</span>
</p>
js
const p01 = document.getElementById("para-01");
console.log(p01.firstChild.nodeName);
html
<p id="para-01"><span>First span</span></p>
js
const p01 = document.getElementById("para-01");
console.log(p01.firstChild.nodeName);