YouTip LogoYouTip

Misc Callbacks Add

# jQuery callbacks.add() Method [![Image 3: jQuery Misc Methods](#)jQuery Misc Methods](#) ## Example Add a function to the callback list $(function(){var foo = function(value){alert("foo: " + value); }; // Another function will be added to the list var bar = function(value){alert("bar: " + value); }; var callbacks = $.Callbacks(); // Add function "foo" to the list callbacks.add(foo); // Call all callback list functions with parameters callbacks.fire("hello"); // Output: "foo: hello" // Add function "bar" to the list callbacks.add(bar); // Call all callback list functions with parameters callbacks.fire("world"); // Output:// "foo: world"// "bar: world"}) [Try it Β»](#) * * * ## Definition and Usage The `callbacks.add()` function is used to add a callback or a collection of callbacks to a callback list. **Note:** This method returns the callback object to which it is bound. * * * ## Syntax callbacks.add( callbacks ) | Parameter | Description | | :--- | :--- | | _callbacks_ | Function, Array type. A function or an array of functions to be added to the callback list. | * * jQuery Misc Methods](#)
← Misc Callbacks DisabledMisc When β†’