jQuery API

callbacks.has()

callbacks.has( callback ) Returns: Boolean

Description: Determine whether a supplied callback is in a list

  • version added: 1.7callbacks.has( callback )

    callbackThe callback to search for.

Example

Using callbacks.has() to check if a callback list contains a specific callback:

// a sample logging function to be added to a callbacks list
var foo = function( value1, value2 ){
    console.log( 'Received:' + value1 + ',' + value2 );
}

// a second function which will not be added to the list
var bar = function( value1, value2 ){
    console.log( 'foobar');
}

var callbacks = $.Callbacks();

// add the log method to the callbacks list
callbacks.add( foo );

// determine which callbacks are in the list

console.log( callbacks.has( foo ) ); // true
console.log( callbacks.has( bar ) ); // false

Support and Contributions

Need help with callbacks.has() or have a question about it? Visit the jQuery Forum or the #jquery channel on irc.freenode.net.

Think you've discovered a jQuery bug related to callbacks.has()? Report it to the jQuery core team.

Found a problem with this documentation? Report it to the jQuery API team.

* All fields are required