I\'m quite new to the on() method in jQuery but the time has come for me to need to use it.
I\'ve two functions for clicking on specific buttons. Each function works
There are two ways to use .on(), and you're using the wrong type.
You can bind event handlers directly to elements using $('selector for elements you want the event handler bound to').on('event', function() {...});
Or, you can delegate events, by calling .on() on a wrapper element that will contain all of the dynamically added elements, such as a div or, in the worst case, the element. Code would look something like this:
$('#wrapper').on('click', '.link', function(e) {
// code to handle the click event on the link here
});
The event handler is actually handled by the link to the div, and the function will also run when they're clicked on.