JavaScript node.removeChild() Method

You are Here:

JavaScript node.removeChild() Method

The node.removeChild() method removes a child node from the DOM and returns the removed node.


HTML Online Editor
<!DOCTYPE html> <html> <body> <ul><li>Honda</li><li>Yamaha</li></ul> <button onclick="myFunction()">Remove Child</button> <script> var y = document.getElementsByTagName("ul")[0]; function myFunction(){ if(y.hasChildNodes()) y.removeChild(y.childNodes[0]); else alert("No child found in ul tag"); } </script> </body> </html>



Parameter Values

childRequiredSpecifies the child node to be removed from the DOM.

Return Values

ObjectReturns an Object, representing the removed node.
NullIf the node does not exist.


Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author