tags:

views:

47

answers:

3

Or how do I know whether this below has been run or not:

$target.bind('click',function() {
...
});
A: 

I use the visual event bookmarklet to show me which items have events.

easement
There's also firequery, a plugin for firebug, but it takes up memory so I disabled it. http://firequery.binaryage.com/
easement
A: 

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
}
David
I need to know whether `click` handler is bound
Updated, have a look.
David
A: 

Borrowing from and extending David's example, use this:

if(typeof $('#id').click == 'function') {}
Wally Lawless
Seems it will always be true