HTML DOM replaceChild() Method Last Updated : 15 Jun, 2023 Comments Improve Suggest changes Like Article Like Report The replaceChild() method in HTML DOM is used to replace a child node with a new node within the given parent node. Syntax: parentNode.replaceChild( newChild, oldChild ) Parameter Values: This method accepts two parameters which are listed below: newChild: It is the required parameter. It represents the new node that needs to be inserted.oldChild: It is the required parameter. It represents the node that is replaced by a new node. Return Value: It returns a node object which represents the replaced node. Example: In this example, the first <li> text is replaced with the new text. HTML <!DOCTYPE html> <html> <head> <title>DOM replaceChild() Method</title> </head> <body> <h1 style="color: green;"> GeeksforGeeks </h1> <h2> DOM replaceChild() Method </h2> <p>Sorting Algorithm</p> <ul id="listitem"> <li>Insertion sort</li> <li>Merge sort</li> <li>Bubble sort</li> </ul> <button onclick="Geeks()"> Click Here! </button> <script> function Geeks() { let doc = document.createTextNode("Quick sort"); let list = document.getElementById("listitem").children[0]; list.replaceChild(doc, list.childNodes[0]); } </script> </body> </html> Output: Supported Browsers: The browser supported by DOM replaceChild() method are listed below: Google Chrome 1Edge 12Internet Explorer 6Firefox 1Opera 7Safari 1.1 Comment More info V Vishal Chaudhary 2 Follow Improve Article Tags : Web Technologies HTML Web technologies HTML-DOM Explore HTML BasicsHTML Introduction5 min readHTML Editors5 min readHTML Basics7 min readStructure & ElementsHTML Elements5 min readHTML Attributes8 min readHTML Headings4 min readHTML Paragraphs5 min readHTML Text Formatting4 min readHTML Block and Inline Elements3 min readHTML Charsets4 min readListsHTML Lists5 min readHTML Ordered Lists5 min readHTML Unordered Lists4 min readHTML Description Lists3 min readVisuals & MediaHTML Colors11 min readHTML Links Hyperlinks3 min readHTML Images7 min readHTML Favicon4 min readHTML Video4 min readLayouts & DesignsHTML Tables10 min readHTML Iframes4 min readHTML Layout4 min readHTML File Paths3 min readProjects & Advanced TopicsHTML Forms5 min readHTML5 Semantics6 min readHTML URL Encoding4 min readHTML Responsive Web Design11 min readTop 10 Projects For Beginners To Practice HTML and CSS Skills8 min readTutorial ReferencesHTML Tags - A to Z List15+ min readHTML Attributes Complete Reference8 min readHTML Global Attributes5 min readHTML5 Complete Reference8 min readHTML5 MathML Complete Reference3 min readHTML DOM Complete Reference15+ min readHTML DOM Audio/Video Complete Reference2 min readSVG Element Complete Reference5 min readSVG Attribute Complete Reference8 min readSVG Property Complete Reference7 min readHTML Canvas Complete Reference4 min read Like