cloneNode() method of the
returns a duplicate of the node on which this method was called.
Its parameter controls if the subtree contained in a node is also cloned or not.
Cloning a node copies all of its attributes and their values,
including intrinsic (inline) listeners. It does not copy event listeners added
those assigned to element properties (e.g.,
node.onclick = someFunction).
Additionally, for a
<canvas> element, the painted image is not copied.
cloneNode() may lead to duplicate element IDs in a document!
If the original node has an
id attribute, and the clone
will be placed in the same document, then you should modify the clone's ID to be
name attributes may need to be modified,
depending on whether duplicate names are expected.
To clone a node to insert into a different document, use
true, then the node and its whole subtree, including text that may be in child
Textnodes, is also copied.
false, only the node will be cloned. The subtree, including any text that the node contains, is not cloned.
let p = document.getElementById("para1") let p_prime = p.cloneNode(true)
|DOM Standard (DOM)|
BCD tables only load in the browser