How to bind a click event to a class .myclass, so that the handler is executed only once for all .myclass elements, and not executed again if the user clicks on another .myclass element.
$('.myclass').one('click', function() {...});
will execute the handler once per .myclass element, but I need the handler to be executed once, for all .myclass elements.
Thanks
Remove the event handler on first click
$('.myclass').on('click.custom', function () {
$('.myclass').off('click.custom');
// do stuff
});
using namespaced events makes sure you remove that handler only, and not other click handlers.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments