DOM Manipulating Elements Removing an element

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

An element can be removed by calling remove() on it. Alternatively, one can call removeChild() on its parent. removeChild() has better browser support than remove().

element.remove();

element, and all its childnodes, are removed from the DOM.

parentElement.removeChild(element);

element, and all its childnodes, are removed from the DOM.

In any case, one can insert this node in the DOM at a later point in time as long as there are still references to this node.



Got any DOM Question?