if you got something like this:
jQuery(selector).focus(function(){...});
jQuery(selector).focus(function(){...});
the focus will trigger twice, is there anyway that I can correct/prevent that?
Use the data('events')
to find event handlers:
var isBound = function(el, ev) {
var found = false;
$.each($(el).data("events"), function(i, e) {
if (i === ev) {
found = true;
}
});
return found;
}
if (!isBound(selector, 'focus')) {
$(selector).bind('focus', fn);
}
I think you can use the .one()
function in jQuery too, have a look at http://api.jquery.com/one/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With