HTML and CSS Reference
Figure 15.21 Creating a table with the DOM from Example 15.11.
To make a copy of a node you can use the cloneNode() method. 2 The cloneNode() method
returns a duplicate of the current node with all of its attributes. It does not become part
of the document; that is, it does not have a parent node, until it is appended to another
node. This method takes only one argument of Boolean type, true or false, which is not
mandatory. If the value is false , then only the node and its attributes are cloned but not
any child nodes (which means any of its text is not cloned). If set to true (deep copy)
then the cloning will include all of its child nodes as well. Caveat: If you clone an ele-
ment and it has an id attribute, you will have to give the cloned node its own id , because
id s must be unique. See Example 15.14.
cloneNode(boolean) /* true : recursive or deep copy; false : copy
current node and attributes, not child
2.To see how cloning can be used effectively with XML documents, see