HTML DOM Element remove() method

Definition and Usage

remove() The method removes an element (or node) from the document.

Note:An element or node is removed from the Document Object Model (DOM).

See also:

removeChild() method

appendChild() method

insertBefore() method

replaceChild() method

childNodes attribute

firstChild attribute

lastChild attribute

firstElementChild attribute

lastElementChild attribute

Example

Remove an element from the document:

const element = document.getElementById("demo");
element.remove();

Try It Yourself

Syntax

element.remove()

or

node.remove()

Parameter

None.

Return Value

None.

Browser Support

element.remove() It is a DOM Living Standard feature.

All modern browsers support it:

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Supported Supported Supported Supported Supported

element.remove() is not supported in Internet Explorer 11 (or earlier versions).