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.
Метод Element.remove()
удаляет элемент из DOM-дерева, в котором он находится.
Синтаксис
js
remove();
Примеры
Использование remove()
html
<div id="div-01">Это div-01</div>
<div id="div-02">Это div-02</div>
<div id="div-03">Это div-03</div>
js
var el = document.getElementById("div-02");
el.remove(); // Удалит элемент div с идентификатором 'div-02'
Область видимости Element.remove()
нерасширяема
Метод remove()
не работает с оператором with
.
Подробнее читайте в справке по Symbol.unscopables
.
js
with (node) {
remove();
}
// ReferenceError: remove is not defined
Спецификации
Specification |
---|
DOM # ref-for-dom-childnode-remove① |
Совместимость с браузерами
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.