I would like to modify a DOM subtree and restore it after a while. How can I save a sub-tree copy aside (to play with the actual subtree)? How can I restore the saved copy a
If I'm reading this right, then I think all you'd need to do is:
var DomTreeCopy = $('parentElementSelector').clone(true,true);
And then to re-attach the DomTreeCopy
(in place of the original):
$('parentElementSelector').replaceWith(DomTreeCopy);
Or to add it to the DOM in addition to the original:
$(DomTreeCopy).insertAfter($('parentElementSelector'));
References: