callbacks.add() appends one or more functions to a jQuery Callbacks list (since jQuery 1.7). It queues handlers; they run when you call fire() or fireWith(). Returns the same Callbacks object for chaining.
Syntax
Start with these common calls. Keep them short and readable.
jQuery
callbacks.add( fn )
callbacks.add( fn1, fn2 ) // multiple args
callbacks.add( [fn1, fn2] ) // array of functions
add() → queue (does not run)
fire() → run every handler in order
returns the Callbacks object (chainable)
Call
What it does
Callbacks object
From $.Callbacks()
callback / array
Function(s) to append
Return
Same Callbacks object (chainable)
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Create a list with $.Callbacks() (optional flags: once, memory, unique, stopOnFalse).
Step 2
Call add(fn) — or pass several functions / an array.
Step 3
Trigger with fire() or fireWith(context, args) when you want handlers to run.
Return Value
Return Value
Description
See examples
Check the examples below for what this API returns in common cases.
First fire. Only the first handler exists → one log line.
Late add. Second handler joins the same list.
Second fire. Both handlers run — the first is not cleared.
Frequently Asked Questions
add() registers one or more functions on a jQuery Callbacks list. Those functions run later when you call fire() or fireWith() on the same list. add() itself does not run the callbacks.
Yes. Pass separate function arguments — callbacks.add(fn1, fn2) — or an array — callbacks.add([fn1, fn2]). Both append handlers in order. The official API accepts a Function or an Array of functions.
Not on a default list. Handlers wait until fire() or fireWith(). With the memory flag, a handler added after the list has already fired runs right away with the last memorized arguments.
By default, duplicates are allowed and each copy runs on fire(). Create the list with $.Callbacks("unique") to reject duplicate references.
After lock(), new add() calls are ignored. After disable(), the list is shut down and further adds and fires are effectively no-ops. Check locked() / disabled() when debugging missing handlers.
jQuery Deferred uses Callbacks lists internally for done, fail, and progress queues (typically with once and memory). Calling .done(fn) is conceptually like add(fn) on that internal list.