How to save and restore all page events using jQuery?

How to save and restore all page events using jQuery?

Hello.
I'm manipulating page html:
$('body').html(changed_html);
And I need save and restore all page events. I can save them something like
var selector = '*'; var s = []; var e; $(selector).addBack().each(function() { e = $._data(this, 'events'); if (!e) return; // console.log(e); console.log(this.tagName); // console.log(this.id); $.each(e, function (i, ev) { console.log(i); $.each(ev, function (j, h) { console.log(h.handler); }); }); });

But what is the best way to restore them?

Thanks in advance.