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 GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
remove |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.