YouTip LogoYouTip

Met Node Replacechild

# HTML DOM replaceChild() Method [![Image 8: Element Object Reference](#) Element Object](#) ## Example Replace a child node with another: document.getElementById("myList").replaceChild(_newnode_,_oldnode_); Before removal: * Coffee * Tea * Milk After removal: * Water * Tea * Milk [Try it Yourself Β»](#) * * * ## Definition and Usage The replaceChild() method replaces a child node with another node. The new node can be one that already exists in the document, or a newly created node. * * * ## Browser Support ![Image 9: Internet Explorer](#)![Image 10: Firefox](#)![Image 11: Opera](#)![Image 12: Google Chrome](#)![Image 13: Safari](#) The replaceChild() method is supported by all major browsers. * * * ## Syntax _node_.replaceChild(_newnode_,_oldnode_) ## Parameters | Parameter | Type | Description | | --- | --- | --- | | _newnode_ | Node object | Required. The node object you want to insert. | | _oldnode_ | Node object | Required. The node object you want to remove. | ## Return Value | Type | Description | | --- | --- | | Node object | The replaced node. | ## Technical Details | DOM Version | Core Level 1 Node Object | | --- | * * Element Object](#)
← Met Element SetattributeMet Node Removechild β†’