jQuery .unbind() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Event Handler

Definition

.unbind() (since 1.0, deprecated 3.0) removes event handlers that were attached with .bind(). Modern code should use .on() / .off() instead.

Syntax

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

jQuery
// Legacy
$("#foo").bind("click", handler);
$("#foo").unbind("click", handler);

// Recommended (jQuery 1.7+)
$("#foo").on("click", handler);
$("#foo").off("click", handler);

// Remove all handlers on the element
$("#foo").unbind();
CallWhat it does
.unbind()Remove all handlers on the elements
.unbind(type)Remove handlers for that event type
.unbind(type, handler)Remove one specific function
.unbind(type, false)Undo .bind(type, false)
.unbind(event)Unbind the current handler from inside itself

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

Parameters

ParameterDescription
typeUsed in .unbind(type). Remove handlers for that event type
handlerUsed in .unbind(type, handler). Remove one specific function
falseUsed in .unbind(type, false). Undo .bind(type, false)
eventUsed in .unbind(event). Unbind the current handler from inside itself

Return Value

Return ValueDescription
See examplesCheck the examples below for what this API returns in common cases.

jQuery Examples

Example 1 — Official Bind / Unbind Demo

Attach a named click handler, then remove that same reference.

jQuery
function aClick() {
  $("#log").text("Handler ran!");
}

$("#bind").on("click", function () {
  $("#theone").bind("click", aClick).text("Can Click!");
});

$("#unbind").on("click", function () {
  $("#theone").unbind("click", aClick).text("Does nothing...");
});
Try It Yourself

How It Works

  1. Name. Store aClick as a shared function.
  2. Bind. .bind("click", aClick) attaches it.
  3. Unbind. Pass the same aClick to remove it.

Example 2 — Unbind by Event Type

Remove every click handler, or wipe all handlers on the element.

jQuery
$("p").bind("click", function () {
  $("#log").text("clicked");
});

$("p").unbind("click"); // all click handlers
// $("p").unbind();    // every handler type
Try It Yourself

How It Works

  1. Attach. Bind a click handler.
  2. Type. .unbind("click") clears all click handlers.
  3. Broad. Bare .unbind() clears every type.

Example 3 — Same Reference Required

Passing a new anonymous function does not remove the original handler.

jQuery
var foo = function () {
  $("#log").text("foo ran");
};

$("button").bind("click", foo);
$("button").unbind("click", foo); // works

// Will NOT work — different function object:
// $("button").unbind("click", function () { … });
Try It Yourself

How It Works

  1. Store. Keep the handler in a variable.
  2. Match. Unbind with that exact reference.
  3. Identity. JS compares objects, not source text.

Frequently Asked Questions

.unbind() removes event handlers attached with .bind(). You can remove all handlers, filter by event type, pass a specific handler reference, use namespaces, or pass an event object from inside a running handler.
Yes, but it has been deprecated since jQuery 3.0. Prefer .off() (available since 1.7) for new code.
Replace .bind(type, fn) with .on(type, fn) and .unbind(type, fn) with .off(type, fn). Namespace forms map the same way: .unbind(".myPlugin") → .off(".myPlugin").
JavaScript compares function references, not source text. .unbind("click", fn) needs the exact same fn passed to .bind(). Store the handler in a named variable.
.unbind() removes direct handlers from .bind(). .off() removes handlers from .on() — direct and delegated — and is the modern replacement for .unbind(), .undelegate(), and .die().
Bind with .bind("click.myEvents", fn), then .unbind("click.myEvents") removes only that binding, or .unbind(".myEvents") removes every handler in the namespace.

Next: Unload Event

Learn the unload browser event and why modern apps prefer pagehide / visibility APIs.

Unload Event 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.

13 people found this page helpful