Web APIs

Node.removeChild()

Try the free JavaScript compiler

Detach a direct child and return it; a node that is not a child triggers NotFoundError. Example console output: true true.

Formal Syntax & Structure

javascript syntaxjavascript
parent.removeChild(child)

Parameters & Attributes

NameTypeDescription
childNodeDirect child to detach.

Return Value

Node

Detached child.

Working Example

Example Snippetjavascript
const p=document.createElement("p"); const t=document.createTextNode("note"); p.append(t); console.log(p.removeChild(t)===t,t.parentNode===null);
JavaScript Reference