Skip to content

Commit

Permalink
Add before and after example
Browse files Browse the repository at this point in the history
  • Loading branch information
ear1grey committed Jan 25, 2024
1 parent 5e66b53 commit 83a1587
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions examples/domA.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>move element</title>

<div>
<h1>Counting</h1>
<p>First</p>
<p id=third>Third</p>
<p>Fifth</p>
<p id="second">Second</p>
<p id="fourth">Fourth</p>
<p id="fourpointfive">Four point five-th</p>
</div>

<script>
// move all paras to destination one
const second = document.querySelector("#second");
const third = document.querySelector("#third");
const fourth = document.querySelector("#fourth");
const fourpointfive = document.querySelector("#fourpointfive");

// move second before third
third.before(second);

// move two elements after the third
third.after(fourth, fourpointfive);
</script>

0 comments on commit 83a1587

Please sign in to comment.