cloneNode Method
Copies a reference to the object from the document hierarchy.
Syntax
oClone = object.cloneNode([bCloneChildren])
Parameters
bCloneChildren Optional. Boolean that specifies one of the following values:
false Default. Cloned objects do not include childNodes. true Cloned objects include childNodes.
Return Value
Returns an element object.
Remarks
The cloneNode method copies an object, attributes, and, if specified, the childNodes.
A collection is returned when referring to the ID of a cloned element.
Example
This example uses the cloneNode method to copy an unordered list and its childNodes.
<SCRIPT> function fnClone(){ /* the 'true' possible value specifies to clone the childNodes as well. */ var oCloneNode = oList.cloneNode(true); /* When the cloned node is added, 'oList' becomes a collection. */ document.body.insertBefore(oCloneNode); } </SCRIPT> <UL ID = oList> <LI>List node 1 <LI>List node 2 <LI>List node 3 <LI>List node 4 </UL> <INPUT TYPE="button" VALUE="Clone List" onclick="fnClone()" >
Applies To
[ Object Name ] Platform Version Win16: Win32: Mac: Unix: WinCE: Version data is listed when the mouse hovers over a link, or the link has focus. A, ACRONYM, ADDRESS, APPLET, AREA, B, BASE, BASEFONT, BDO, BGSOUND, BIG, BLOCKQUOTE, BODY, BR, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, COMMENT, DD, DEL, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM, FRAME, FRAMESET, HEAD, Hn, HR, HTML, I, IFRAME, IMG, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=hidden, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, INS, KBD, LABEL, LEGEND, LI, LINK, LISTING, MAP, MARQUEE, MENU, NEXTID, OBJECT, OL, OPTION, P, PLAINTEXT, PRE, Q, S, SAMP, SCRIPT, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TITLE, TR, TT, U, UL, VAR, XMP
See Also
Did you find this topic useful? Suggestions for other topics? write us!
© 1999 microsoft corporation. all rights reserved. terms of use.