Name
Node.cloneNode( ): duplicate a node and, optionally, all of its descendants — DOM Level 1 Core
Synopsis
Node cloneNode(booleandeep);Arguments
-
deep If this argument is
true,cloneNode( )recursively clones all descendants of this node. Otherwise, it clones only this node.
Returns
A copy of this node.
Description
The cloneNode( ) method
makes and returns a copy of the node on which it is called. If
passed the argument true, it
recursively clones all descendants of the node as well. Otherwise,
it clones only the node and none of its children. The returned node
is not part of the document tree, and its parentNode property is null. When an Element node is cloned, all
of its attributes are also cloned. Note, however, that
event-listener functions registered on a node are not cloned.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access