Easy Tutorial
❮ Misc Callbacks Remove Traversing Not ❯

jQuery callbacks.has() Method

jQuery Miscellaneous Methods

Example

Use callbacks.has() to check if a callback has been added to the list.

$(function () { 
    // A simple function to be added to the list
    var foo = function( value1, value2 ) {
        alert( "Received: " + value1 + "," + value2 );
    };
    // A second function which will not be added to the list
    var bar = function( value1, value2 ) {
        alert( "foobar" );
    }
    var callbacks = $.Callbacks();
    // Add the function to the list
    callbacks.add( foo ); 
    alert( callbacks.has( foo ) );
    // true
    alert( callbacks.has( bar ) );
    // false
})

Definition and Usage

The callbacks.has() function is used to determine if a specific callback function has been added to the callback list.


Syntax

Parameter Description
callback Function type to search for in the callback list

jQuery Miscellaneous Methods

❮ Misc Callbacks Remove Traversing Not ❯