JavaScript
Beginner
Dom
· 1 min read
Remove a DOM node
How do I delete an element?
element.remove().
Example
Interactive preview availableconst note = document.querySelector('#toast');
note?.remove();
Line-by-Line Walkthrough
Modern browsers support Element.remove().