Ad

How To Make A JQuery Object Contains A Snapshot Of Dom Object?

- 1 answer

I found that a JQuery object contains a pointer to a DOM object, and the context of the Jquery object would change with the HTML being modified. However, I'd like to record Logs and I don't want the Jquery Object in the history records to change, what should I do?

Ad

Answer

You can use the jQuery clone function: https://api.jquery.com/clone/

var original = $('selector');
var copy = original.clone();

Now if you change original, the copy won't be changed.

Ad
source: stackoverflow.com
Ad