Or how do I know whether this below has been run or not:
$target.bind('click',function() {
...
});
Or how do I know whether this below has been run or not:
$target.bind('click',function() {
...
});
I use the visual event bookmarklet to show me which items have events.
You can access the jQuery.data
object to find out:
$.fn.isBound = function() {
return this.length && typeof $.data(this[0], 'handle') == 'function' || false;
}
if ($target.isBound()) {
// $target has events
}
UPDATE: if you want to check for specific types you can look in the events
object:
$.fn.isBound = function(type) {
return this.length && $.data(this[0], 'events')[type] || false;
}
if ($target.isBound('click')) {
// $target has clickevents
}
Borrowing from and extending David's example, use this:
if(typeof $('#id').click == 'function') {}