jQuery callbacks.remove() Method — Unregister Handlers

Beginner
5 min read
Updated: Nov 2026
3 examples
Callbacks

Definition

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.

Syntax

Start with these common calls. Keep them short and readable.

jQuery
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
CallWhat it does
callbacksFunction or array of functions to remove
ReturnSame Callbacks object (chainable)

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
Step 1Store handlers in named variables.
Step 2add() them to the list and use fire() as needed.
Step 3Call remove(fn) or remove([fn1, fn2]) to unsubscribe.

Return Value

Return ValueDescription
jQuery objectMost setters and traversing helpers return the jQuery collection so you can chain more methods.

jQuery Examples

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.

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.

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.

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: callbacks.empty() Method — Clear All Handlers

Clear every handler from a Callbacks list in one call.

callbacks.empty() Method — Clear All Handlers tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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