Easy Tutorial
❮ Prop Style Liststyletype Met Document Getelementsbytagname ❯

HTML DOM cloneNode() Method

Element Object

Example

Copy an list item to another list:

Before copying:

After copying:


Definition and Usage

The cloneNode() method creates an exact copy of the specified node.

The cloneNode() method copies all attributes and their values.

This method will clone and return a copy of the node it is called on. If the parameter passed to it is true, it will also recursively clone all descendants of the current node. Otherwise, it only clones the current node.


Browser Support

All major browsers support the cloneNode() method.


Syntax

Parameters

Parameter Type Description
deep Boolean Optional. This method will clone and return a copy of the node it is called on. If the parameter passed to it is true, it will also recursively clone all descendants of the current node. Otherwise, it only clones the current node. <br>

Return Value

Type Description
Node Object The copied node

Technical Details

| DOM Version | Core Level 1 Node Object | | --- | --- |


Element Object

❮ Prop Style Liststyletype Met Document Getelementsbytagname ❯