MDN self-hosted library · e01.org

Element: remove() method

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

html
<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>
js
const element = document.getElementById("div-02");
element.remove(); // Removes the div with the 'div-02' id
js
with (node) {
  remove();
}
// ReferenceError: remove is not defined