The ChildNode.remove() method removes the object from the tree it belongs to.




Using remove()

<div id="div-01">Here is div-01</div>
<div id="div-02">Here is div-02</div>
<div id="div-03">Here is div-03</div>
var el = document.getElementById('div-02');
el.remove(); // Removes the div with the 'div-02' id

ChildNode.remove() is unscopable

The remove() method is not scoped into the with statement. See Symbol.unscopables for more information.

with(node) { 
// ReferenceError: remove is not defined 


You can polyfill the remove() method in Internet Explorer 9 and higher with the following code:

// from:
(function (arr) {
  arr.forEach(function (item) {
    if (item.hasOwnProperty('remove')) {
    Object.defineProperty(item, 'remove', {
      configurable: true,
      enumerable: true,
      writable: true,
      value: function remove() {
        if (this.parentNode !== null)
})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);


Specification Status Comment
The definition of 'ChildNode.remove' in that specification.
Living Standard Initial definition.

Browser compatibility

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support (on Element) 23.0 (Yes) 23.0 (23.0) No support[1] 10.0 7.0
Support on CharacterData and DocumentType 29.0 (Yes) 23.0 (23.0) No support 16.0 7.0
Feature Android Android Webview Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile Chrome for Mobile
Basic support (on Element) (Yes) (Yes) (Yes) 23.0 (23.0) No support 10.0 No support (Yes)
Support on CharacterData and DocumentType (Yes) (Yes) (Yes) 23.0 (23.0) No support 16.0 No support (Yes)

[1] IE supports the non-standard removeNode(bool) function, where the bool argument indicates whether the child nodes of the given element should also be removed. MSDN: removeNode 

See also

Document Tags and Contributors

 Last updated by: erikadoyle,