The removeChild() method in HTML DOM is used to remove a specified child node of the given element. It returns the removed node as a node object or null if the node doesn’t exist.
Syntax:
node.removeChild( child )
Parameters: This method accepts single parameter child which is mandatory. It represents the node which need to be remove.
Return Value: It returns a node object which represents the removed node, or null if the node doesn’t exist.
Example:
<!DOCTYPE html> <html> <head> <title> HTML DOM removeChild() Method </title> </head> <body> <h1 style="color: green;"> GeeksforGeeks </h1> <h2> DOM removeChild() Method </h2> <p>Sorting Algorithm</p> <ul id = "listitem"><li>Insertion sort</li> <li>Merge sort</li> <li>Quick sort</li> </ul> <button onclick = "Geeks()"> Click Here! </button> <script> function Geeks() { var doc = document.getElementById("listitem"); doc.removeChild(doc.childNodes[0]); } </script> </body> </html> |
Output:
Before click on the button:

After click on the button:

Supported Browsers: The browser supported by DOM replaceChild() method are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- PHP | DOMNode removeChild() Function
- HTML | DOM contains() Method
- HTML | DOM after() Method
- HTML | DOM before() method
- HTML | DOM cloneNode() Method
- HTML | DOM exitFullscreen() Method
- HTML DOM matches() Method
- HTML | DOM replaceChild() Method
- HTML | DOM toggleAttribute() Method
- HTML | DOM write() Method
- HTML | DOM isDefaultNamespace() Method
- HTML DOM setStartAfter() method
- HTML | DOM isSameNode() Method
- HTML DOM deleteFromDocument() method
- HTML | DOM hasAttributes() Method
- HTML | DOM Select add Method
- HTML | DOM removeNamedItem() Method
- HTML | DOM getAttributeNode() Method
- HTML | DOM setRangeText() method
- HTML | DOM execCommand() Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


