The cloneNode() method creates a copy of a node, and returns the newly clone node.
The cloneNode() method is supported in all major browsers.
Parameter | Type | Description |
---|---|---|
deep | Boolean | true clones the node, its attributes, and its descendants.
false clones the node and its attributes. |
Type | Description |
---|---|
Node object | The cloned node |
DOM Version | Core Level 1 Node Object |
---|
The following code fragment loads "books.xml" into xmlDoc using loadXMLDoc(), clones the first <book> node and then adds it to the end of the node list:
Output: