JavaScript Beginner Dom · 1 min read

Remove a DOM node

Start the JavaScript learning path »

❮ JavaScript Home All Tutorials ❯

How do I delete an element?

element.remove().

Example

Interactive preview available
JavaScript Example
const note = document.querySelector('#toast');
note?.remove();

Line-by-Line Walkthrough

Modern browsers support Element.remove().

Need more coins?

You do not have enough coins for this action.

Your balance: 0 coins

Share

Reactions

Loading reactions…