DOM Node.removeChild() Method
The removeChild() method removes a child node from its parent and returns it.
Description
The removeChild() method removes a child node from the parent and returns it. The removed node still exists in memory and can be inserted elsewhere. The simpler element.remove() removes an element without needing a reference to its parent.
If the node isn't a child of the parent you call it on, it throws a NotFoundError, so the common pattern was node.parentNode.removeChild(node), which remove() now replaces. Removing a node also removes all of its descendants. Event listeners stay attached to the removed node, so if you re-insert it, it keeps working.
Removing many children one at a time can be slow; to empty an element entirely, element.replaceChildren() with no arguments, or setting textContent to an empty string, removes all children in one step.
Syntax
parent.removeChild(child)Parameters
- childThe child node to remove.
Return Value
The removed node.
Exceptions
- NotFoundErrorThrown if the node is not a child of the parent.
Example
Browser Support
The following information will show you the current browser support for the Node.removeChild() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





