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]

DOM How-To


Web Scripting Overview


HTML Input


Web Scripting Examples


Web Scripting Misc


jQuery


node.js

Like it? Help me by telling your friends. Or, Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials