jQuery callbacks.remove() Method — Unregister Handlers

Beginner
5 min read
Updated: Oct 2026
4 examples
Live preview

What Is remove()?

callbacks.remove(callbacks) removes a function — or an array of functions — from a Callbacks list (since jQuery 1.7). Later fire() calls skip those handlers. Returns the same Callbacks object for chaining.

Remember
callbacks.add(foo)
callbacks.fire("hello")   // foo runs
callbacks.remove(foo)
callbacks.fire("world")   // nothing — foo is gone

remove(fn)        // one handler
remove([a, b])    // several at once
NeedUse
Registercbs.add(fn)
Unregister one / somecbs.remove(fn) or cbs.remove([a, b])
Clear allcbs.empty()
Still registered?cbs.has(fn)

How to Use remove()

Keep the reference, then remove it when you unsubscribe.

  1. Store handlers in named variables.
  2. add() them to the list and use fire() as needed.
  3. Call remove(fn) or remove([fn1, fn2]) to unsubscribe.
  4. Optional: confirm with has(fn) — expect false.
PieceRequired?Role
callbacksYesFunction or array of functions to remove
Return—Same Callbacks object (chainable)

Pseudocode

Pseudocode
function remove(callbacks, targets):
    for each fn in (targets as list):
        if fn is in callbacks.list:   // reference match
            delete fn from list
    return callbacks

Cheat Sheet

Targeted unsubscribe — not a full clear.

TopicDetail
Syntaxcallbacks.remove(callbacks)
SincejQuery 1.7
ArgumentFunction or Array of functions
Match ruleSame function object (identity)
Cousinsadd / empty / has

Live Preview

Add, fire, remove, and fire again — watch which handlers still run.

Browser demo of callbacks.remove() — same idea as the examples below.

Result
Ready — pick an action and click Run.

jQuery Examples

Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.

Example 1 — Remove One Handler

Official style: add, fire, remove, fire again.

jQuery
var foo = function (value) {
  console.log("foo: " + value);
};

var callbacks = $.Callbacks();
callbacks.add(foo);
callbacks.fire("hello");
// foo: hello

callbacks.remove(foo);
callbacks.fire("world");
// (no output)
Try It Yourself

How It Works

  1. Add the named function foo.
  2. First fire runs foo.
  3. remove(foo) drops that same reference.
  4. Second fire has nothing left to call.

Example 2 — Remove Several at Once

Pass an array to unregister more than one handler.

jQuery
var lines = [];
var a = function () { lines.push("a"); };
var b = function () { lines.push("b"); };
var c = function () { lines.push("c"); };

var cbs = $.Callbacks();
cbs.add(a).add(b).add(c);
cbs.remove([a, b]);
cbs.fire();
console.log(lines.join(""));  // "c"
Try It Yourself

How It Works

  1. Add three handlers.
  2. remove([a, b]) drops two of them.
  3. fire runs only c.
  4. API. Argument may be one function or an array.

Example 3 — Confirm With has()

Membership flips after a successful remove.

jQuery
var onReady = function () {
  console.log("ready");
};

var cbs = $.Callbacks();
cbs.add(onReady);
console.log(cbs.has(onReady));  // true

cbs.remove(onReady);
console.log(cbs.has(onReady));  // false
Try It Yourself

How It Works

  1. add registers onReady.
  2. has returns true.
  3. remove the same reference.
  4. has returns false.

Example 4 — remove() vs empty()

Pick one handler to drop, or clear the whole list.

jQuery
var lines = [];
var keep = function () { lines.push("keep"); };
var drop = function () { lines.push("drop"); };

var cbs = $.Callbacks();
cbs.add(keep).add(drop);
cbs.remove(drop);   // only drop is gone
cbs.fire();
console.log(lines.join(","));  // keep

cbs.empty();        // clears keep too
cbs.fire();
console.log(lines.join(","));  // keep (unchanged)
Try It Yourself

How It Works

  1. remove(drop) leaves keep on the list.
  2. First fire prints keep.
  3. empty() clears every remaining handler.
  4. Second fire adds nothing new to lines.

Edge Cases & Pitfalls

Most failures come from losing the original function reference.

identity

Anonymous twins do not match

add(function(){}) then remove(function(){}) fails — different objects, same text.

empty

Need a full reset?

Use empty() instead of removing every handler one by one.

missing

Removing a missing handler is safe

remove(fn) quietly does nothing if fn is not on the list.

fired

Does not reset fired()

Removing handlers does not clear the fired flag — that tracks past fire() / fireWith() calls.

Browser Support

callbacks.remove() has shipped since jQuery 1.7 with $.Callbacks. It works in all modern browsers with jQuery loaded.

✓ jQuery 1.7+

callbacks.remove()

Unregister a function or array of functions from the Callbacks list.

100% Browser support
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
callbacks.remove() Excellent

Bottom line: Pass the same function reference you added. Use empty() when you need to clear everything.

Performance Notes

ApproachCostBest for
remove(fn)O(n) scanDrop one subscriber
remove([a,b])O(n × k)Drop a small batch
empty()O(1) clearWipe the whole list

Lists are usually short. Prefer named handlers and targeted remove for unsubscribe paths.

Key Takeaways

  • Role: unregister specific handlers.
  • Args: one function or an array of them.
  • Identity: same reference you add()ed.
  • vs empty: remove some; empty clears all.

One line: remove(fn) unsubscribes the same function object you added.

Frequently Asked Questions

remove(callbacks) unregisters a function — or an array of functions — from a Callbacks list. Later fire() calls no longer invoke those handlers. It returns the same Callbacks object for chaining.
Yes. remove() matches by identity, just like has(). Keep a named variable for the handler you add(), then pass that same variable to remove().
remove(fn) drops specific handlers. empty() clears every handler on the list at once.
Yes. Pass an array: callbacks.remove([foo, bar]). You can also pass a single function.
remove() is safe — it simply finds nothing to remove and returns the Callbacks object. No error is thrown.
Unsubscribe a plugin listener, clean up a specific subscriber on destroy, or drop one handler while leaving others on the list.

Next: empty()

Clear every handler from a Callbacks list in one call.

empty() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful