jQuery .undelegate() Method

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

Definition

.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);
CallWhat it does
RootSame element used with .delegate()
selectorDescendant filter — must match the bind
eventTypee.g. "click" or "click.ns"
handlerSame function reference to remove one handler

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

Parameters

ParameterDescription
Step 1Attach with $(root).delegate(selector, events, handler).
Step 2Remove with $(root).undelegate(selector, events, handler) on that same root.
Step 3Pass the same function reference when removing one specific handler.

Return Value

Return ValueDescription
See examplesCheck 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...");
});
Try It Yourself

How It Works

  1. Delegate. The handler is stored on body for #theone clicks.
  2. Bubble. Clicks on the target bubble up and run aClick.
  3. Undelegate. The same root, selector, type, and function remove it.

Example 2 — Remove All Delegated Handlers

Official pattern: .undelegate() with no arguments on the root.

jQuery
$("#list").delegate("li", "click", function () {
  $("#log").text("Click: " + $(this).text());
});

$("#off-all").on("click", function () {
  $("#list").undelegate();
  $("#log").text("All delegated handlers removed.");
});
Try It Yourself

How It Works

  1. Root. Handlers were delegated on #list.
  2. Clear. No-arg .undelegate() drops every delegated entry on that root.
  3. Scope. Direct handlers on #list itself are not the target of this call.

Example 3 — Remove by Event Type

Official pattern: .undelegate("click") removes delegated clicks only.

jQuery
$("#list").delegate("li", "click", function () {
  $("#log").text("Delegated click ran.");
});
$("#list").delegate("li", "mouseenter", function () {
  $("#log").text("Delegated mouseenter ran.");
});

$("#unbind-click").on("click", function () {
  $("#list").undelegate("click");
  $("#log").text("Delegated click removed. Hover still works.");
});
Try It Yourself

How It Works

  1. Two types. Click and mouseenter are both delegated on #list.
  2. Filter. One-arg .undelegate("click") targets click only.
  3. 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().

Next: .live() Method

See another legacy delegation API and how it maps to .on().

.live() Method 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