replaceNode Method

DHTML, HTML, & CSS

 
Click to return to the DHTML, HTML & CSS home page    
replaceChild Method     reset Method     DHTML Methods    

replaceNode Method


Replaces the object with another element.

Syntax

oReplace = object.replaceNode(oNewNode)

Parameters

oNewNodeRequired. Object that specifies the new element to replace the object.

Return Value

Returns a reference to the object that is replaced.

Remarks

When a node is replaced, all values associated with the replaced object are removed. For example, if a B object is replaced with an I object, any attributes and text between the opening and closing tags are also replaced. To preserve these values, copy them to the new element before the original object is replaced.

This method 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.

Example

This example uses the replaceNode method to replace an unordered list with an ordered list.

<SCRIPT>
function fnReplace(){
   var sPreserve = oList.innerHTML;
   var oNewNode = document.createElement("OL");
   oList.replaceNode(oNewNode);
   oNewNode.innerHTML = sPreserve;
}
</SCRIPT>

<UL ID = oList>
<LI>List Item 1
<LI>List Item 2
<LI>List Item 3
<LI>List Item 4
</UL>
<INPUT TYPE = button VALUE = "Replace List" onclick = "fnReplace()">

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
Version data is listed when the mouse hovers over a link, or the link has focus.
A, ACRONYM, ADDRESS, B, BDO, BIG, BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, COMMENT, DD, DEL, DFN, DIR, DIV, DL, DT, EM, FIELDSET, FONT, FORM, FRAMESET, HEAD, Hn, HTML, I, IFRAME, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, INS, KBD, LABEL, LEGEND, LI, LISTING, MAP, MARQUEE, MENU, NEXTID, OBJECT, OL, OPTION, P, PLAINTEXT, PRE, Q, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP

See Also

replaceChild

Back to topBack to top

Did you find this topic useful? Suggestions for other topics? write us!Internet Link

© 1999 microsoft corporation. all rights reserved. terms of useInternet Link.