I volontari di MDN non hanno ancora tradotto questo articolo in Italiano. Unisciti a noi e traducilo tu stesso.
Puoi anche consultare l’articolo in English (US).

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:https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/remove()/remove().md
(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

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic supportChrome Full support 23Edge Full support 12Firefox Full support 23IE No support NoOpera Full support 15Safari Full support 7WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 23Opera Android Full support 10Safari iOS Full support 7Samsung Internet Android Full support Yes


Full support  
Full support
No support  
No support

See also

Tag del documento e collaboratori

Ultima modifica di: mdnwebdocs-bot,