Tags

, , ,

If you have used .remove() method for dynamically remove and append element somewhere inside the DOM then event binding will not work on that particular element, for that we can use .detach() method , this will provide you return object of element removed and then you can append that element/Object inside DOM so that event bind on that particular element will remains as it is.

Also please note if you are creating element dynamically than bind jquery event with .on() method.

issue faced during

  • removing DOM element on document.ready()
  • appending it to Other DOM element on document.ready();
  • now attaching event listeners
  • but still event listeners was not working due to .remove() was use
  • i applied fix with .detach()  method
Advertisements