CRUD OPERATION IN DOM :
1. CREATE:
<h1 id="one">hello</h1>
<h2 id="two">have a good day</h2>
<button id="three" onclick="change()">click me</button>
<script>
const btn = document.getElementById("three")
const h2 = document.getElementById("two")
const h1 = document.getElementById("one")
function change(){
const newesttag = document.createElement("p");
newesttag.innerText = "keerthana"
document.body.insertBefore(newesttag,h2)
}
</script>
OUTPUT:


Top comments (0)