Getting DOM events after saving in Session Javascript

function setItemStates() {
    savedItemState = $('#my-items').clone(true, true);
    sessionStorage.setItem('savedItemState', savedItemState.html());
function getItemStates() {
    var domElem = sessionStorage.getItem('savedItemState');
    domElem = $(domElem);
    $('body').html(domElem) // No events or state


I am looking for a way to return my DOM events after I have cloned and saved the session.


source to share

1 answer

I think you will have to use delegated event handlers instead of binding events directly to your element.

For example:

$(document).on("click", "#my-items", function(e) {



$("#my-items").on("click", function(e) {




All Articles