Element.remove()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

El método Element.remove() elimina un elemento del DOM.

Sintaxis

js
remove()

Parámetros

Ninguno.

Valor de retorno

Ninguno (undefined).

Ejemplos

Utilizando remove()

html
<div id="div-01">Aquí está el div-01</div>
<div id="div-02">Aquí está el div-02</div>
<div id="div-03">Aquí está el div-03</div>
js
const element = document.getElementById("div-02");
element.remove(); // Elimina el div con el id 'div-02'

Element.remove() no se puede recorrer

El método remove() no está incluido en la sentencia with. Véase Symbol.unscopables para más información.

js
with (node) {
  remove();
}
// ReferenceError: remove no está definido

Especificaciones

Specification
DOM
# ref-for-dom-childnode-remove①

Compatibilidad con navegadores

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
remove

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

Véase también