There are no tracking or monitoring cookies on this site. There are only cookies used for documentation examples related to cookies.Close
Processing...
This may take a few seconds.

clone

Note: This command has an issue that will be resolved in an upcoming release. Its functionality is limited. If it works for you now, great! Otherwise don't use it yet.

Syntax

clone: (selector) [every (time)] [after (time)];

Make a deep copy of a node to memory. To restore the node later on, use the restore-clone command.

In simpler terms, it will copy the target selector itself, and all elements underneath it in the DOM tree.

For an example of a practical use, we use this along with restore-clone for all the "Reset example" links in our examples. We clone the example when first drawn, and when the user hits "Reset example", it puts the original example back into the same place, overriding any changes that may have occurred.

Note: This command uses the JavaScript document.importNode command to make the copy before it stores it in memory. For more information on that, and what a deep copy is, see here:

https://developer.mozilla.org/en-US/docs/Web/API/Document/importNode

clone