The removeChild() method removes a specified child node from the current node.
Tip: The removed child node can be inserted later into any element in the same document. Use the insertBefore() or appendChild() method to insert it later into the same document, or use the adoptNode() or importNode() method to insert the removed node into another document.
The removeChild() method is supported in all major browsers.
Parameter | Type | Description |
---|---|---|
child | Node object | Required. The node to remove |
Type | Description |
---|---|
Node object | Returns the removed node as a Node object |
DOM Version | Core Level 1 Node Object. Modified in DOM Level 3 |
---|
The following code fragment loads "books.xml" into xmlDoc using loadXMLDoc() and removes the first child node in the first <book> node:
Output: