jQuery .live() Method

Beginner
7 min read
Updated: Oct 2026
5 examples
Live preview

What Is .live()?

.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)
NeedUse
New delegated handlers.on(events, selector, handler)
Legacy live attach.live(events, handler) (removed 1.9)
Remove live handlers.die() (removed 1.9)
Choose a closer root.delegate() / modern .on()
Modern unbind.off()

How to Use .live()

Only when reading or migrating pre-1.9 code. New work should use .on().

  1. Select the elements that should match (the selector becomes the live key).
  2. Call .live(events, handler) — jQuery attaches at document.
  3. Add matching elements later; they still trigger the handler.
  4. Remove with .die() using the same selector (legacy) or rewrite to .off().
  5. Prefer a closer root: $(root).on(events, selector, handler).
FormSinceRole
.live(events, handler)1.3Bind one or more event types
.live(events, data, handler)1.4Also pass event.data
.live(eventsMap)1.4.3Object 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)

Cheat Sheet

Quick facts for legacy code reviews.

TopicDetail
ReturnsjQuery (but chaining after .live() is unreliable)
Added1.3 · data 1.4 · events map 1.4.3
Deprecated1.7
Removed1.9
RootAlways document
Remove.die() / modern .off()
Migrate$(sel).live(ev, fn) → $(document).on(ev, sel, fn)

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.

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("

Another paragraph!

"); });
Try It Yourself

How It Works

  1. Bind. One document-level handler for clicks matching "p".
  2. Match. Bubbled targets are tested against that selector.
  3. Act. this is the clicked paragraph; append a sibling.
  4. Future. New paragraphs match automatically — no rebind.

Example 2 — return false

Cancel default action and stop bubbling from a live link handler.

jQuery
$("a").live("click", function () {
  $("#out").text("Blocked navigation");
  return false; // preventDefault + stopPropagation
});

// Or cancel default only:
// event.preventDefault();
Try It Yourself

How It Works

  1. Live. Clicks on any a (including future ones) reach document.
  2. Return false. Blocks navigation and further bubbling.
  3. Note. Before 1.7, stopPropagation() alone often failed to stop other live handlers — return false was safer.
  4. Modern. Same idea with $(document).on("click", "a", …).

Example 3 — Migrate to .on()

Official rewrite templates — same behavior, modern API.

jQuery
// Legacy
$("a.offsite").live("click", fn);

// Intermediate
$(document).delegate("a.offsite", "click", fn);

// Preferred (1.7+)
$(document).on("click", "a.offsite", fn);
Try It Yourself

How It Works

  1. Live. Selector is on the jQuery collection; root is fixed to document.
  2. Delegate / on. Root is explicit; selector moves into the call.
  3. Order. .on(events, selector, handler) — events first.
  4. Bonus. You can attach on a closer parent than document.

Example 4 — Event Data

Pass data the same way as other jQuery event APIs.

jQuery
$("button").live("click", { source: "toolbar" }, function (event) {
  $("#out").text($(this).text() + " · " + event.data.source);
});
Try It Yourself

How It Works

  1. Pass. The middle argument becomes event.data.
  2. Live. Still document-delegated for matching buttons.
  3. Read. Handler uses both this and event.data.
  4. Modern. $(document).on("click", "button", data, fn).

Example 5 — Events Map

Bind several live handlers in one object (1.4.3+).

jQuery
$("p").live({
  click: function () {
    $(this).after("

Another paragraph!

"); }, mouseover: function () { $("#out").text("over: " + $(this).text()); } });
Try It Yourself

How It Works

  1. Map. Each key is an event type; each value is a handler.
  2. Live. All are registered as document-level live handlers.
  3. Dynamic. New paragraphs get both behaviors automatically.
  4. Modern. $(document).on({ click: fn, mouseover: fn2 }, "p").

Edge Cases & Pitfalls

Reasons .live() was replaced — and traps in old code.

removed

Missing on jQuery 1.9+

$(…).live is not a function means you need to rewrite to .on().

chain

No chaining before .live()

$("a").find(".offsite").live(…) does not work as expected — bind with a full selector instead.

path

Always the longest bubble path

Every live event must reach document. Prefer a closer root with .on().

off

$(document).off("click") is dangerous

It can remove every click handler attached via .live() — another reason to migrate carefully.

Browser Support

.live() existed from jQuery 1.3 to 1.8. It was deprecated in 1.7 and removed in 1.9. Current jQuery builds do not include it.

✓ Removed · jQuery 1.3–1.8

.live()

Not available in jQuery 1.9+. Use $(document).on(events, selector, handler) for all new and upgraded projects.

Removed Use .on() instead
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
.live() Removed 1.9

Bottom line: Historical API only. Migrate live/die pairs to on/off when you touch legacy code.

Performance Notes

ApproachCostBest for
.on() on a close rootLowModern lists, tables, dynamic UI
.live() on documentHigher path costLegacy only — migrate away
Selecting a huge set before .live()WastefuljQuery still queried matches first — avoid

Delegation is good; document-only delegation is the slowest form. Closer roots with .on() filter fewer unrelated bubbles.

Key Takeaways

  • Role: document-level delegation for current and future matches.
  • Status: deprecated 1.7, removed 1.9 — not in modern jQuery.
  • Migrate: $(sel).live(ev, fn) → $(document).on(ev, sel, fn).
  • Remove: .die() historically; prefer .off() today.

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.

Next: .die()

See how to remove handlers attached with .live().

.die() tutorial →

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