jQuery callbacks.has() method
Example
Use callbacks.has() to check whether 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 a function to the list
callbacks
.
add
(
foo
)
;
alert
(
callbacks
.
has
(
foo
)
)
;
//
true
alert
(
callbacks
.
has
(
bar
)
)
;
//
false
}
)
Try it »
Definition and Usage
The callbacks.has() function is used to determine whether a callback function has been added to a callback list.
Syntax
callbacks.has( callback )
| Parameters | Description |
|---|---|
| callback | Function type: the callback function to search for |
jQuery Miscellaneous Methods