The .unbind() method removes direct event handlers attached with .bind(). Deprecated since jQuery 3.0 and superseded by .off() since 1.7, it still appears in legacy themes and plugins. This tutorial explains all official signatures, five worked examples, namespace cleanup, migration to .off(), and why new code should never use it.
01
Syntax
.unbind(type, fn)
02
Pair
Undoes .bind()
03
By ref
Same function
04
Namespaces
.unbind(".ns")
05
Migrate
Use .off()
06
Dep 3.0
Legacy only
Fundamentals
Introduction
Before jQuery 1.7 unified event handling with .on() and .off(), developers used .bind() to attach direct handlers and .unbind() to remove them. For years this pair was the standard way to wire up click, submit, and custom events on elements already in the DOM.
As of jQuery 3.0, .unbind() is deprecated. It still executes in jQuery 3.x for backward compatibility, but the official recommendation is .off() — which handles direct handlers, delegated handlers, and namespaces in one API. Understanding .unbind() helps you read and migrate older codebases.
Concept
Understanding .unbind()
.unbind() only removes handlers attached via .bind() on the element itself — not delegated handlers from .delegate() or .live(). When you call $("#btn").unbind("click", handler), jQuery detaches that specific function from the click event registry on #btn.
Like .off(), you can omit arguments for broad removal, filter by event type, target a namespace, pass the handler function reference, or pass the event object from inside a running handler to remove itself.
💡
Beginner Tip
Never try to .unbind() an anonymous inline function — JavaScript treats each function literal as a unique object. Always store handlers in named variables: var fn = function() { ... }; then .bind("click", fn) and .unbind("click", fn).
Foundation
📝 Syntax
Four signatures from the official jQuery API (all deprecated since 3.0):
Only affects handlers bound with .bind() (or shortcut methods that use the same registry).
Cheat Sheet
⚡ Quick Reference
Goal
Code
Remove all handlers
$("#foo").unbind()
Remove all click handlers
$("#foo").unbind("click")
Remove one handler by ref
$("#foo").unbind("click", fn)
Remove namespace handlers
$("#foo").unbind(".myEvents")
Self-remove in handler
$(this).unbind(event)
Modern replacement
$("#foo").off("click", fn)
Status
Deprecated jQuery 3.0
Compare
📋 .unbind() vs .off() vs .die() vs .undelegate()
Four unbinding methods from different jQuery eras. Only .off() should be used in new projects.
.unbind()
.bind() pair
Direct handlers only — deprecated 3.0
.off()
.on() pair
Modern unified unbind since 1.7 — recommended
.undelegate()
.delegate() pair
Delegated on root — deprecated 3.0
.die()
.live() pair
Document-level — removed 1.9
Hands-On
Examples Gallery
All five examples follow the official jQuery API documentation for .unbind(). Try-it labs use .bind() / .unbind() to demonstrate the legacy pair accurately.
📚 Official API Examples
Five patterns from api.jquery.com/unbind/.
Example 1 — Bind and Unbind Click on a Button
The official interactive demo: bind aClick with .bind(), then remove it with matching .unbind().
Click "Bind Click" → #theone shows "Can Click!"
Click #theone → div flashes and fades
Click "Unbind Click" → .unbind removes handler
#theone reverts to "Does nothing..."
How It Works
The control buttons use modern .on(); the target button uses legacy .bind() / .unbind(). The same function reference aClick must be passed to both methods.
Example 2 — Remove All Event Handlers
Calling .unbind() with no arguments clears every handler on matched elements.
Before: click and mouseenter handlers on each p
After $("p").unbind(): no handlers remain
Modern equivalent: $("p").off()
How It Works
No filters means jQuery removes all direct handlers from each matched element. Use carefully in shared code — prefer namespaces or specific handler references.
Example 3 — Remove All Click Handlers
Filter by event type to remove only click handlers, leaving other event types intact.
p has click + mouseenter bound
.unbind("click") → clicks ignored
mouseenter still works
Equivalent: .off("click")
How It Works
Passing an event type string removes all handlers for that type on the element, regardless of namespace (unless you include the namespace in the string).
Example 4 — Remove One Handler by Function Reference
Official pattern: store foo in a variable so .unbind("click", foo) targets exactly one handler.
jQuery
var foo = function() {
// Code to handle some kind of event
};
$( "p" ).bind( "click", foo );
$( "p" ).unbind( "click", foo );
Two click handlers bound on p
.unbind("click", foo) removes only foo
Second handler still runs
Identical inline functions CANNOT be unbound this way
How It Works
JavaScript identity comparison requires the same function object. The API explicitly warns that rebinding an identical anonymous function and trying to unbind a different anonymous copy will fail.
Example 5 — Remove Handlers by Namespace
Plugin-friendly cleanup: bind under .myEvents, remove all at once with .unbind(".myEvents").
click.myEvents + mouseenter.myEvents on #foo
.unbind(".myEvents") removes BOTH
Plain click handler without namespace still works
Migrate to .off(".myEvents")
How It Works
Namespaces segment your plugin’s handlers from other code. Passing only ".myEvents" removes every handler with that namespace, regardless of event type — the same rule applies to modern .off().
Applications
🚀 Why You Still See .unbind()
Legacy WordPress themes — older jQuery plugins bound with .bind() and cleaned up with .unbind().
Maintenance & migration — read existing code before replacing with .off().
Toggle binding pattern — official bind/unbind button demo from Example 1.
Self-removing handlers — $(this).unbind(event) after N clicks (migrate to .off(event) or .one()).
Plugin teardown — .unbind(".myPlugin") in destroy methods (prefer .off(".myPlugin") today).
jQuery learning history — understand how .off() unified three legacy unbind APIs.
🧠 How .unbind() Finds Handlers to Remove
1
Parse filters
jQuery reads event type, namespace, handler function, or event object from your arguments.
Parse
2
Scan .bind() registry
It searches direct handlers on each matched element — the same registry .bind() wrote to.
Match
3
Detach matches
Matching handlers are removed and will no longer fire on that element.
Remove
4
🔄
Migrate to .off()
In jQuery 1.7+, .off() uses the same filter logic but covers handlers from .on() as well.
Important
📝 Notes
.unbind() was deprecated in jQuery 3.0; use was discouraged since 1.7 when .off() shipped.
Only removes direct handlers from .bind() — not .delegate(), .live(), or .on() delegated handlers.
Proxied handlers ($.proxy()) share one internal id — unbinding one proxied handler may affect others; use namespaces.
.unbind(event) inside a handler removes the currently executing binding — same as .off(event).
.unbind("click", false) removes handlers bound with .bind("click", false) since jQuery 1.4.3.
Modern migration: replace every .bind() / .unbind() pair with .on() / .off() using identical arguments for direct binding.
Compatibility
Browser Support
.unbind() is a deprecated jQuery method available in jQuery 1.x, 2.x, and 3.x. It works in browsers your jQuery version supports but should not be used in new code. Use .off() instead — supported since jQuery 1.7 and the only recommended unbind API.
✓ Deprecated 3.0
jQuery .unbind()
Still executes in jQuery 3.x for backward compatibility but deprecated since 3.0. Read and migrate legacy code to .off(). Never use in new projects.
LegacyDeprecated API
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
.unbind()Use .off()
Bottom line: Do not use .unbind() in new jQuery code. Migrate to .off() with the same event type, namespace, and handler reference. See the .off() tutorial for the modern API.
Wrap Up
Conclusion
jQuery .unbind() was the original way to remove direct event handlers paired with .bind(). Deprecated since version 3.0 and superseded by .off() since 1.7, it remains important for reading legacy code and completing migrations.
Every .unbind() pattern has a direct .off() equivalent for handlers bound with .on(). When you encounter .unbind() in the wild, migrate the binding to .on() first, then swap the unbind call to .off(). Next: the unload event with .on("unload").
Use .one() instead of manual .unbind(event) for one-shot handlers
❌ Don’t
Write new code with .bind() / .unbind() in jQuery 3 projects
Try to .unbind() a different anonymous function copy
Expect .unbind() to remove delegated or .live() handlers
Call $("body").unbind() casually — removes all direct handlers on body
Ignore deprecation warnings in the browser console during upgrades
Summary
Key Takeaways
Knowledge Unlocked
Six things to remember about .unbind()
Legacy direct unbind — migrate to .off().
6
Core concepts
📝01
.bind() pair
Direct only.
Legacy
🗑02
.off()
Modern fix.
Migrate
fn03
By ref
Same function.
Rule
.ns04
Namespace
.unbind(".ns")
Plugins
evt05
Self-off
.unbind(event)
Pattern
3.006
Deprecated
Don’t use new.
Status
❓ Frequently Asked Questions
.unbind() removes event handlers that were attached with .bind(). It is the legacy direct-unbinding API. You can remove all handlers, filter by event type, pass a specific handler function reference, use namespaces, or pass an event object from inside a running handler.
.unbind() still works in jQuery 3.x but has been deprecated since jQuery 3.0. Do not use it in new code. Replace .bind() / .unbind() with .on() / .off(), which support both direct and delegated handlers.
Direct migration is one-to-one: $('#btn').bind('click', fn) becomes $('#btn').on('click', fn), and $('#btn').unbind('click', fn) becomes $('#btn').off('click', fn). Namespace syntax is identical: .unbind('.myPlugin') becomes .off('.myPlugin').
JavaScript compares function references, not function bodies. .unbind('click', fn) requires the exact same fn passed to .bind(). Two identical inline functions are different objects — store the handler in a named variable.
.unbind() only removes direct handlers bound with .bind(). .off() removes handlers bound with .on() — both direct and delegated — and replaces .unbind(), .undelegate(), and conceptually .die(). Use .off() in all modern projects.
If you bound with .bind('click.myEvents', fn), call .unbind('click.myEvents') to remove only that handler, or .unbind('.myEvents') to remove all handlers in the namespace regardless of event type.
Did you know?
When jQuery 1.7 introduced .on() and .off(), the documentation already marked .bind() and .unbind() as legacy. It took until jQuery 3.0 for the deprecation to become official — but the migration path was available for eight years before that. Most codebases that still use .unbind() today simply were never updated.