JavaScript Element remove() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
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.

JavaScript
el.remove()
CallWhat 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
JavaScript
el.remove()

Parameters

This member has no parameters beyond those shown in the signature.

Return Value

Return ValueDescription
*Always undefined

JavaScript Examples

Example 1 — Remove an Element (MDN)

Delete the middle div by id.

JavaScript
const el = document.getElementById("div-02");
el.remove();

console.log(document.getElementById("div-02")); // null
Try It Yourself

How It Works

  1. Find the element. getElementById("div-02") returns the node.
  2. Call remove(). The node is detached from its parent (MDN).
  3. Look it up again. getElementById returns null.
  4. Siblings stay. Other elements in the parent are unchanged.

Example 2 — Remove on Click

Dismiss a notice when the user clicks the button.

JavaScript
const note = document.getElementById("note");
const btn = document.getElementById("close");

btn.addEventListener("click", () => {
  note.remove();
  console.log("note removed");
});
Try It Yourself

How It Works

  1. Select notice and button. Store both elements.
  2. Listen for click. User dismisses the notice.
  3. Call note.remove(). The notice leaves the page.
  4. 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.

JavaScript
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
Try It Yourself

How It Works

  1. Keep a variable. item still points at the node after remove.
  2. Call remove(). It leaves the parent but is not destroyed.
  3. Call append(). The same node is attached again.
  4. Check parent. parentNode matches the list.

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.

Wide Baseline
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

It removes the element from its parent node in the DOM. If the element has no parent, calling remove() does nothing (MDN).
No. MDN marks Element.remove() as Baseline Widely available (across browsers since July 2015). It is not Deprecated, Experimental, or Non-standard.
None. Call it with empty parentheses: element.remove() (MDN).
undefined. There is no return value (MDN).
remove() is called on the element you want to delete. removeChild() is called on the parent and takes the child as an argument.
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().

Next: removeAttribute()

Learn how to remove an attribute from an element.

removeAttribute() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

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