revision:
The Element.remove() method removes the element from the DOM.
element.remove() node.remove()
Parameters:none
<p id="demo">Click "Remove", and this paragraph will be removed from the DOM.</p> <button onclick="myFunction()">Remove</button> <script> function myFunction() { const element = document.getElementById("demo"); element.remove(); } </script>
<div> <div id="div-01">Here is div-01</div> <div id="div-02">Here is div-02</div> <div id="div-03">Here is div-03</div> </div> <script> const element = document.getElementById("div-02"); element.remove(); // Removes the div with the 'div-02' id </script>