Previous Element Sibling

Access the previous sibling element.

Preview

Code

<p>First</p>
<p id="second">Second</p>

<script>
let el = document.getElementById("second");

console.log(el.previousElementSibling);
</script>

More JS DOM Navigation Examples (7)