.live(events, handler) attaches a handler for elements matching the current selector — now and in the future — by binding at document (since 1.3). Removed in 1.9 in favor of .on().
Remember
// Legacy (jQuery ≤ 1.8)
$("a.offsite").live("click", function () {
alert("Goodbye!");
});
// Same idea with successors
$(document).delegate("a.offsite", "click", fn); // 1.4.3+
$(document).on("click", "a.offsite", fn); // 1.7+ (preferred)
Only when reading or migrating pre-1.9 code. New work should use .on().
Select the elements that should match (the selector becomes the live key).
Call .live(events, handler) — jQuery attaches at document.
Add matching elements later; they still trigger the handler.
Remove with .die() using the same selector (legacy) or rewrite to .off().
Prefer a closer root: $(root).on(events, selector, handler).
Form
Since
Role
.live(events, handler)
1.3
Bind one or more event types
.live(events, data, handler)
1.4
Also pass event.data
.live(eventsMap)
1.4.3
Object of event → handler pairs
Pseudocode
Pseudocode
$(SELECTOR).live(EVENTS, HANDLER)
≈ attach on document for EVENTS
when event bubbles to document:
if original target matches SELECTOR:
run HANDLER with this = matched element
new matching elements:
work automatically
modern rewrite:
$(document).on(EVENTS, SELECTOR, HANDLER)
Reference
Cheat Sheet
Quick facts for legacy code reviews.
Topic
Detail
Returns
jQuery (but chaining after .live() is unreliable)
Added
1.3 · data 1.4 · events map 1.4.3
Deprecated
1.7
Removed
1.9
Root
Always document
Remove
.die() / modern .off()
Migrate
$(sel).live(ev, fn) → $(document).on(ev, sel, fn)
Try it
Live Preview
Modern .on() stand-in for .live() — new items stay clickable (works in current jQuery).
Click any item — then add items and click those too. True .live() demos are in Try It Yourself (jQuery 1.8.3).
Log
Ready — click an item or run an action.
Code
jQuery Examples
Legacy patterns for reading old code. Prefer .on() in new projects. Try It Yourself runs on jQuery 1.8.3.
Example 1 — Dynamic Children
Click a paragraph to append another — new ones stay clickable.
jQuery
$("p").live("click", function () {
$(this).after("
One line:.live() was early document delegation — learn it to read old code, write new code with .on().
Frequently Asked Questions
.live(events, handler) attaches a delegated handler for elements matching the selector — now and in the future. jQuery binds at the document, so later-added matches still fire without rebinding.
No. .live() was deprecated in 1.7 and removed in 1.9. Use $(document).on(events, selector, handler) instead. jQuery Migrate 1.x can restore .live()/.die() temporarily while upgrading.
Replace $(selector).live(events, handler) with $(document).on(events, selector, handler). Example: $('a.offsite').live('click', fn) → $(document).on('click', 'a.offsite', fn). Remove with .die() → $(document).off(...).
.live() always attaches at document. .delegate() lets you choose a closer root (often faster). Both are legacy; .on() replaced them in 1.7.
Handlers always travel to document (slow path), chaining like .find().live() fails, iOS click bubbling is awkward, and $(document).off('click') can wipe every .live() click handler. .on() fixes these issues.
Use .die() on the same selector (also removed in 1.9). Modern code uses .off() with the same event and delegation selector.