.delegate(selector, eventType, handler) attaches a handler on a root element for events from matching descendants — including elements added later (since 1.4.2). Argument order differs from .on().
Remember
// Deprecated (3.0+) — selector first
$("table").delegate("td", "click", function () {
$(this).toggleClass("chosen");
});
// Modern equivalent — events first (1.7+)
$("table").on("click", "td", function () {
$(this).toggleClass("chosen");
});
Bind once on a stable parent; filter by child selector when the event bubbles up.
Pick a root that will stay in the DOM (list, table, form, or body).
Call .delegate(selector, eventType, handler) on that root.
Inside the handler, this is the matched descendant that triggered the event.
Add or remove matching children later — no rebind needed.
In new code, write the same idea with .on(eventType, selector, handler).
Piece
Required?
Role
selector
Yes
Filter which descendants may trigger the handler
eventType / events
Yes
Event name(s), or a map of events → handlers (1.4.3+)
eventData
Optional
Data passed to the handler via event.data
handler
Yes*
Function to run (*not needed when using an events map)
Pseudocode
Pseudocode
attach listener on ROOT for EVENT
when EVENT bubbles to ROOT:
find original target
if target matches SELECTOR (or is inside a match):
run HANDLER with this = matched element
else:
ignore
new children that match SELECTOR:
work automatically — no extra bind
Reference
Cheat Sheet
Keep these mappings handy while reading legacy code.
Topic
Detail
Returns
jQuery (chainable)
Since
1.4.2 · events map 1.4.3
Deprecated
jQuery 3.0 → use .on()
Migrate
.delegate(sel, ev, fn) → .on(ev, sel, fn)
Remove
.undelegate() / modern .off()
this
Matched descendant (not the root)
Propagation
stopPropagation() below the root can block the handler
Try it
Live Preview
One .delegate() on the list — new items stay clickable.
Click any list item below — then add items and click those too.
Log
Ready — click an item or run an action.
Code
jQuery Examples
Short, copy-ready snippets. Prefer rewriting these with .on() in new projects.
Example 1 — Dynamic Children
Click a paragraph to append another — new ones stay clickable.
jQuery
$("body").delegate("p", "click", function () {
$(this).after("
One line:.delegate() is legacy event delegation — learn it to read old code, write new code with .on().
Frequently Asked Questions
.delegate(selector, eventType, handler) attaches a handler on a root element for events from matching descendants — now or added later. One parent listener covers many children.
Yes. As of jQuery 3.0, .delegate() is deprecated. Prefer .on(events, selector, handler) since jQuery 1.7. The method still works for legacy code, but new projects should not use it.
.live() always delegated from the document and could not choose a closer root. .delegate() lets you pick the parent (table, list, form). .live() was removed in 1.9; .delegate() was superseded by .on() and deprecated in 3.0.
You bind once on a stable parent instead of many handlers on each child. New elements added later still work without rebinding, and memory use stays lower on long lists.
Use .undelegate() for handlers attached with .delegate(), or migrate to .on() / .off(). Prefer .off(events, selector, handler) in modern code.