jQuery callbacks.has()Method

jQuery 杂项方法jQuery Miscellaneous Methods

Example

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

$(function () { //A simple function that will 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 })

Try it Yourself »

Definition and Usage

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


Syntax

callbacks.has( callback )

Parameters Description
callback Function type The callback function to search for


jQuery 杂项方法jQuery Miscellaneous Methods

Other Extensions