jQuery callbacks.empty()Method
Examples
Remove all callbacks from the list
$(function () {
//A simple function that will be added to the list
var foo = function( value1, value2 ) {
alert( "foo: " + value1 + "," + value2 );
}
//Another function that will be added to the list
var bar = function( value1, value2 ){
alert( "bar: " + value1 + "," + value2 );
}
var callbacks = $.Callbacks();
//Add the two functions
callbacks.add( foo );
callbacks.add( bar );
//Empty the callback list
callbacks.empty();
//Check whether all callbacks have been removed from the list
alert( callbacks.has( foo ) );
// false
alert( callbacks.has( bar ) );
// false
})
Try it Yourself »
Definition and Usage
The callbacks.empty() function is used to remove all callbacks from the list.
This method returns a callback object to the callback list it is bound to.
Syntax
This method does not accept any parameters.
callbacks.empty()
Other Extensions
jQuery Miscellaneous Methods