Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery callbacks.empty() method

jQuery callbacks.empty() method

jQuery Miscellaneous MethodsjQuery Miscellaneous Methods

Example

Remove all callbacks from the list

$

(

function

(

)

{

//

A simple function to be added to the list

var

foo

=

function

(

value1

,

value2

)

{

alert

(

"

foo:

"

value1

"

,

"

value2

)

;

}

//

Another function to be added to the list

var

bar

=

function

(

value1

,

value2

)

{

alert

(

"

bar:

"

value1

"

,

"

value2

)

;

}

var

callbacks

= $.

Callbacks

(

)

;

//

Add two functions

callbacks

.

add

(

foo

)

;

callbacks

.

add

(

bar

)

;

//

Empty the callback list

callbacks

.

empty

(

)

;

//

Confirm whether all callbacks in the list have been removed

alert

(

callbacks

.

has

(

foo

)

)

;

//

false

alert

(

callbacks

.

has

(

bar

)

)

;

//

false

}

)

Try it »


Definition and Usage

The callbacks.empty() function is used to remove all callbacks from the list.

This method returns a callbacks object to the callback list it is bound to.


Syntax

This method does not accept any parameters.

callbacks.empty()


jQuery Miscellaneous MethodsjQuery Miscellaneous Methods