DEV Community

Keerthana M
Keerthana M

Posted on

CRUD OPERATION

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>
Enter fullscreen mode Exit fullscreen mode

OUTPUT:

Top comments (0)