This question already has an answer here:
- Direct vs. Delegated - jQuery .on() 4 answers
Hi I have a Ajax call that I'm doing with jQuery and was wondering what is the difference between these methods on selecting an element on click,
FIRST
$(this).on('click', 'button', function (){ });
SECOND
$('button').on('click', function (){ });
THIRD
$('button').click(function { });
My Ajax call selects new data from my database and updates the content on success and changes the data from a data object that I have on the button with an ID, the first on works but the second and third once both only work once and then it fails and I'm am wondering why, thanks a lot in advance!
this
is, the other two are regular click events, and are the same. – adeneo Jun 15 at 21:55this
is. It might not mean anything at all... – lonesomeday Jun 15 at 21:56