0

In my HTML , I have a table in which each row has a button , upon clicking the button on any row, it changes the html of that row, to an edit view. Once the user clicks save, the HTML goes back to the original content and the fields are updated. But now when the button is clicked upon again, the change event is not firing, even though the ID is still correct.

Any idea on why this could be happening?

EDIT: I am currently using the $(selector).click() syntax.

  • Can you please reproduce the same on JS Fiddle or Code Sandbox? It would become easier to debug. – priyanshu sinha May 05 '20 at 07:37
  • You are binding the handler to an element when it is in the DOM, and replacing it with a new element. So the handler is lost. Look at event delegation which can solve your issue – Sushanth -- May 05 '20 at 07:37
  • Thanks for the replies, I figured out the issue, using the .on("click") syntax seems to fix the issue – Vivek Nichani May 05 '20 at 08:12

0 Answers0