In jquery, we can clone an element and all its events with clone()
method. Example:
$(".element").clone(true);
How can we do the same thing with native Javascript?
I'm updating my post.
In jquery, we can clone an element and all its events with clone()
method. Example:
$(".element").clone(true);
How can we do the same thing with native Javascript?
I'm updating my post.
You can try like this:
myelement = oldelement.cloneNode(deep)
From MDN:
The Node.cloneNode() method returns a duplicate of the node on which this method was called.
deep Optional
true if the children of the node should also be cloned, or false to clone only the specified node.