MDN self-hosted library · e01.org

Element: lastElementChild property

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

html
<ul id="list">
  <li>First (1)</li>
  <li>Second (2)</li>
  <li>Third (3)</li>
</ul>
js
const list = document.getElementById("list");
console.log(list.lastElementChild.textContent);
// logs "Third (3)"