JavaScript cloneNode example

As it is clear with its name that it clones the node. JavaScript cloneNode() method creates a clone copy of the given node object and returns the clone node object.

JavaScript cloneNode example

As it is clear with its name that it clones the node.
JavaScript cloneNode() method creates a clone copy of the given node object and
returns the clone node object. In our this sample code we have created a clone
node copy of the button object.

Syntax:

elementObject.cloneNode(boolean);

It accepts only one argument of boolean type which is
not mandatory. If its value is "false" it doesn't include the
child nodes and if its "true" then it will include the child
nodes as well.

Description of code:

In our example code for creating a clone of given node
object we have created a page in which we have included a button with the id
"button" when user clicks on it then it calls functionClone(),
which is defined in our JavaScript function that it will clone the node
object by getting the button object with the id "button". It
will show the clone object in the alert message. Full source code for it is as
given below:

janaki Govindan
October 14, 2011
Id of the cloned object
By cloning the object, we create another cloned obj with the same id. Is there any way of changing the object's id?
if im cloning a row containing 4 text boxes, 3 check boxes and 6 drop-downs,
my cloned row contains the same elements with the same ID. how can i dynamically change my cloned element's IDs?