.undelegate() (since 1.4.2) removes handlers attached with .delegate() on a root element. Filter by selector, event type, handler, or namespace. It is deprecated since 3.0 — use .off() instead.
Syntax
Start with these common calls. Keep them short and readable.
jQuery
// Legacy (deprecated since 3.0)
$("body").delegate("p", "click", fn);
$("body").undelegate("p", "click", fn);
// Modern — argument order swaps for .off()
$("body").on("click", "p", fn);
$("body").off("click", "p", fn);
Call
What it does
Root
Same element used with .delegate()
selector
Descendant filter — must match the bind
eventType
e.g. "click" or "click.ns"
handler
Same function reference to remove one handler
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Attach with $(root).delegate(selector, events, handler).
Step 2
Remove with $(root).undelegate(selector, events, handler) on that same root.
Step 3
Pass the same function reference when removing one specific handler.
Return Value
Return Value
Description
See examples
Check the examples below for what this API returns in common cases.
jQuery Examples
Example 1 — Bind then Undelegate
Official pattern: attach with .delegate(), remove with .undelegate().
jQuery
function aClick() {
$("#log").text("Delegated click ran!");
}
$("#bind").on("click", function () {
$("body").delegate("#theone", "click", aClick);
$("#theone").text("Can Click!");
});
$("#unbind").on("click", function () {
$("body").undelegate("#theone", "click", aClick);
$("#theone").text("Does nothing...");
});
Keep others. mouseenter remains until you remove it too.
Frequently Asked Questions
.undelegate() removes event handlers that were attached with .delegate() on a root element. It can filter by descendant selector, event type, handler function reference, or namespace. Prefer .off() in new code.
Yes, it still works in jQuery 3.x but has been deprecated since jQuery 3.0. Do not use it in new projects. Replace .delegate() / .undelegate() with .on() / .off().
Swap parameter order: $("body").undelegate("p", "click", fn) becomes $("body").off("click", "p", fn). Namespace cleanup: .undelegate(".whatever") becomes .off(".whatever"). Use the same root element as .delegate().
.undelegate() removes delegated handlers from .delegate(). .unbind() removes direct handlers from .bind(). Both are deprecated; .off() replaces both.
If you bound with .delegate("#theone", "click", fn), call .undelegate("#theone", "click", fn) on the same root. A mismatched selector or wrong root will not remove the handler.
All delegated event handlers on the matched root elements are removed. It does not remove direct .bind() / .on() handlers on those elements — only delegation entries from .delegate().