DOM - Sibling Manipulation

DOM - Sibling Manipulation

About

This page is about Sibling manipulation in the DOM

Method

insertAdjacent

What is InsertAdjacent and InsertAdjacentHTML and how to use them ? can insert at this positions:

<!-- beforebegin -->
<element>
  <!-- afterbegin -->
  text
  <!-- beforeend -->
</element>
<!-- afterend -->

Selector

See Sibling selector

nextElementSibling

<p>First</p>
<p>Second</p>
let p = document.querySelector("p");
console.log(p.nextElementSibling.innerText);

Documentation / Reference





Discover More
Domtree
DOM - Node

In DOM, every markup in an (XML|HTML) document is a node represented in a tree view. Every DOM node has at least: a , a name, and a value, which might or might not be empty. Node Type...



Share this page:
Follow us:
Task Runner