Skip to main content Accessibility Feedback

DOM Injection

Element.remove()

Remove an element from the DOM. Call the Element.remove() method on the element you want to remove.

<h1>Hello, world!</h1>
let h1 = document.querySelector('h1');
h1.remove();

Preorder my new course on Web Components! Want to learn how to build Web Components from scratch, master best practices, and more? Preorder today and get $100 off of the launch price.


Find this useful? You can support my work by purchasing an annual membership.