replaceChild method

Replaces an existing child element with a new child element.


IHTMLDOMNode retVal = object.replaceChild(newChild, oldChild);


  • newChild [in]
    Type: [IHTMLDOMNode](aa704078(v=vs.85).md)

    IDispatch that specifies the new element to be inserted into the document.

  • oldChild [in]
    Type: [IHTMLDOMNode](aa704078(v=vs.85).md)

    IDispatch that specifies the existing element to be replaced.

Standards information


The node to be replaced must be an immediate child of the parent object. The new node must be created using the IHTMLDocument2::createElement method.

This property is accessible at run time. If elements are removed at run time, before the closing tag is parsed, areas of the document might not render.

Windows Internet Explorer 9. Exceptions are only supported when webpages are displayed in IE9 Standards mode.

In Microsoft Internet Explorer 6, This method now applies to the attribute object.