Click to return to the DHTML, HTML     
click Method     close Method     DHTML Methods    
Web Workshop  |  DHTML, HTML & CSS

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:
falseDefault. Cloned objects do not include childNodes.
trueCloned 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 ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
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

appendChild, insertBefore



Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.