DOM: Remove HTML Element

By Xah Lee. Date: . Last updated: .

Here's how to remove an HTML/XML element.

const x = document.getElementById("i10231");

x.parentNode.removeChild(x);

Remove All Children

node.innerHTML = ""

const t = document . getElementById ("abc");

// remove all children
t.innerHTML = '';

[see DOM: Difference Between textContent, innerHTML, innerText, nodeValue]

βˆ‘ JS in Depth
XAH Β BUY NOW

JS in Depth

JS Obj Ref

DOM


DOM

Overview

Basic Examples

HTML Input

Web Scripting Examples

Web Scripting Misc

jQuery

node.js