• Home
  • Uncategorized
  • Binding events to elements that are dynamically recreated, or document dynamically redraws

Binding events to elements that are dynamically recreated, or document dynamically redraws

This can be done with jquery as below:

$('div').on('click', 'a#CancelScripts', function() {
  console.log("Cancelling scripts..");
  localStorage.setItem('GotoBeginning', false);
  localStorage.setItem('GotoLast', false);
  return false;
});

Here, div is the parent element of tag that we wish to bind click to.