Home JavaScript Element Methods remove() JavaScript Element remove() Method Definition Element.remove() removes the element from its parent node (MDN). If it has no parent, the call does nothing. Returns undefined.
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax Call el.remove. Start with this line.
Call What it does el.remove()Primary signature. el.remove(...)Call with the arguments your case needs.
Built into the browser. Call remove(...) on an Element — no import required.
Library declarations Parameters This member has no parameters beyond those shown in the signature.
Return Value Return Value Description * Always undefined
JavaScript Examples 1. Remove an element 2. Remove on click 3. Keep & re-insert Example 1 — Remove an Element (MDN) Delete the middle div by id.
const el = document.getElementById("div-02");
el.remove();
console.log(document.getElementById("div-02")); // null How It Works Find the element. getElementById("div-02") returns the node.Call remove(). The node is detached from its parent (MDN).Look it up again. getElementById returns null.Siblings stay. Other elements in the parent are unchanged.Example 2 — Remove on Click Dismiss a notice when the user clicks the button.
const note = document.getElementById("note");
const btn = document.getElementById("close");
btn.addEventListener("click", () => {
note.remove();
console.log("note removed");
}); How It Works Select notice and button. Store both elements.Listen for click. User dismisses the notice.Call note.remove(). The notice leaves the page.No parent needed. You do not call removeChild on a parent.Example 3 — Keep a Reference & Re-insert Remove from the DOM, then put the same node back.
const list = document.getElementById("list");
const item = document.getElementById("item");
item.remove(); // detached, but `item` still holds the node
list.append(item); // back in the document
console.log(item.parentNode === list); // true How It Works Keep a variable. item still points at the node after remove.Call remove(). It leaves the parent but is not destroyed.Call append(). The same node is attached again.Check parent. parentNode matches the list.Compatibility
Browser Support Element.remove() is Baseline Widely available on MDN (across browsers since July 2015). Safe for everyday DOM cleanup.
✓ Baseline Widely available
Element.remove() Remove an element from its parent — widely supported.
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Android WebView Supported · Modern WebView
Full support remove() Widely available
Bottom line: Call el.remove() on the element itself. Prefer over parent.removeChild(el) for simple deletes. No-op if already detached.
Frequently Asked Questions What does Element.remove() do? It removes the element from its parent node in the DOM. If the element has no parent, calling remove() does nothing (MDN).
Is remove() deprecated or experimental? No. MDN marks Element.remove() as Baseline Widely available (across browsers since July 2015). It is not Deprecated, Experimental, or Non-standard.
What parameters does remove() take? None. Call it with empty parentheses: element.remove() (MDN).
What does remove() return? undefined. There is no return value (MDN).
How is remove() different from removeChild()? remove() is called on the element you want to delete. removeChild() is called on the parent and takes the child as an argument.
Can I undo remove()? Not automatically. The node is detached but still exists in memory if you keep a reference — you can re-insert it with append() or appendChild().
About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
22 people found this page helpful
Helpful Share Copy link Suggestion