Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1087595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:57:36+00:00 2026-05-16T22:57:36+00:00

I read in another question that you’d use live if there wasn’t a container

  • 0

I read in another question that you’d use live if there wasn’t a container to attach the event to with $.delegate that you knew wasn’t going away, but why not simply do:

$('body').delegate('.myThing', 'click', function() { ... });

I’ve become fairly convinced that there’s no reason to use $.live() in any new code and that its only still here for backwards compatibility.

Of course, I’m often wrong. So I’m asking: When would I use $.live instead of $.delegate and why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:57:36+00:00Added an answer on May 16, 2026 at 10:57 pm

    $.live()

    …is slightly more concise if you don’t need to use a specific element for the context.

    $.delegate()

    …is slightly more convenient if you already have a context selected, especially if you’re chaining to perform other operations on that context.

    …is slightly more efficient, provided you’re not performing any other operations on the target elements, in that it doesn’t needlessly evaluate the target selector during binding.

    …allows you to target multiple contexts, which live() does not (though see implementation note below).

    Otherwise, it’s a matter of personal preference. You can accomplish the same things with both methods – indeed, the current (as of 1.4.2) implementation of delegate merely delegates to live!

    delegate: function( selector, types, data, fn ) {
            return this.live( types, data, fn, selector );
        }
    

    Implementation note

    Even though you could effectively use the current implementation of live() as a substitute for all forms of delegate(), you should avoid calling live() the way delegate() calls it – the undocumented fourth parameter is intended for internal use only. Normally, you would provide a context for live() the way you would provide a context to any jQuery selector – by passing the element as the second parameter to $():

    $(selector, contextElem).live(...);
    

    If you need to use a selector for the context (as in a scenario where you wish to bind delegated events to multiple, separate context elements) you should stick to using delegate():

    $("body>div").delegate(selector, ...);
    

    Demonstration

    // all of these are the same - pick the shortest form that fits your needs:
    $(document).delegate('.myThing', 'click', function() { ... });
    $('.myThing', document).live('click', function() { ... });
    $('.myThing').live('click', function() { ... });
    
    // this should only be done using delegate
    $("#myTable, #myDiv, #myMarquee").delegate('.myThing', 'click', function(){...});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've read another similiar question on SO but there wasn't a clear answer at
I read in another question that you can increase the JRE memory allowance for
I read on another Stack Overflow question that Python was just like Ruby, as
Of the two methods below, which do you prefer to read? Is there another
I know there is this question that is very similar, but I wanted to
I have read another post/question regarding jquery variables and it was useful but I'm
I have another question to security in the web world. So I read (and
In .Net you can read a string value into another data type using either
I am trying to read an XML-file from another server. However the the company
What's the most efficient way to read a stream into another stream? In this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.