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 177471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:03:37+00:00 2026-05-11T14:03:37+00:00

I have been doing some reading up on jquery live event and am still

  • 0

I have been doing some reading up on jquery live event and am still kind of confused? What is the benefit to using it?

http://docs.jquery.com/Events/live

I know it is similar to bind but both of those events still seem off to me.

Just looking for some pointers.

  • 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. 2026-05-11T14:03:38+00:00Added an answer on May 11, 2026 at 2:03 pm

    Warning: This answer is old. Still very useful, but live has been deprecated and removed in newer versions of jQuery. So read the answer, because the use cases haven’t changed, and you will learn why and when to use less event handlers. But unless you are still using a really old version of jQuery (v1.4.2 or prior), you should considerer writing the new equivalent code instead. As documented in the jQuery API for live and copied here:

    Rewriting the .live() method in terms of its successors is straightforward; these are templates for equivalent calls for all three event attachment methods:

    1. $( selector ).live( events, data, handler ); // jQuery 1.3+
    2. $( document ).delegate( selector, events, data, handler ); // jQuery 1.4.3+
    3. $( document ).on( events, selector, data, handler ); // jQuery 1.7+

    Sometimes you have a set of elements when the page loads, like, say, edit links:

    <table>   <tr>     <td>Item 1</td>     <td><a href='#' class='edit'>Edit</a></td>   </tr>   <tr>     <td>Item 2</td>     <td><a href='#' class='edit'>Edit</a></td>   </tr>   <tr>     <td>Item 3</td>     <td><a href='#' class='edit'>Edit</a></td>   </tr> </table> 

    Now, maybe you have something like this with jQuery:

    $(document).ready(function() {   $('a.edit').click(function() {     // do something     return false;   }); }); 

    But what if you add a new element to this table dynamically, after the page has initially loaded?

    $('table').append('     <tr><td>Item 4</td><td><a href='#' class='edit'>Edit</a></td></tr> '); 

    When you click on ‘Edit’ on this new Item, nothing will happen because the events were bound on page load. Enter live. With it, you can bind the event above like this:

    $(document).ready(function() {   $('a.edit').live('click', function() {     // do something     return false;   }); }); 

    Now if you add any new <a> elements with a class of edit after the page has initially loaded, it will still register this event handler.

    But how is this accomplished?

    jQuery uses what is known as event delegation to achieve this functionality. Event delegation is helpful in this situation or when you want to load a large amount of handlers. Say you have a DIV with images:

    <div id='container'>     <img src='happy.jpg'>     <img src='sad.jpg'>     <img src='laugh.jpg'>     <img src='boring.jpg'> </div> 

    But instead of 4 images, you have 100, or 200, or 1000. You want to bind a click event to images so that X action is performed when the user clicks on it. Doing it as you might expect…

    $('#container img').click(function() {     // do something }); 

    …would then bind hundreds of handlers that all do the same thing! This is inefficient and can result in slow performance in heavy webapps. With event delegation, even if you don’t plan on adding more images later, using live can be much better for this kind of situation, as you can then bind one handler to the container and check when it is clicked if the target was an image, and then perform an action:

    // to achieve the effect without live... $('#container').click(function(e) {     if($(e.target).is('img')) {         performAction(e.target);     } });  // or, with live: $('img', '#container').live('click', function() {     performAction(this); }); 

    Since jQuery knows that new elements can be added later on or that performance is important, instead of binding an event to the actual images, it might add one to the div like in the first example (in reality, I’m pretty sure it binds them to the body but it might to the container in the example above) and then delegate. This e.target property can let it check after the fact if the event that was clicked/acted on matches the selector that you might have specified.

    To make it clear: this is helpful not only in the direct way of not having to rebind events, but it can be dramatically faster for a large amount of items.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been doing some testing whilst using Jquery UI datepicker and have found
I have been doing some reading on this subject, but I'm curious to see
I have been doing some catching up lately by reading about cloud hosting. For
I have been doing some reading, and I see that I can use getch()
I have been doing some reading lately one article I read was from Opera.
Although I have been discouraged from reading the OpenGL redbook, I am still doing
I have been doing some reading in preparation for starting my first WCF project
I've been doing some reading recently and have encountered the Law of Demeter. Now
I've been doing some simple web programming using python, and I have a basic
I've been doing some reading into designing template code have a question about it.

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.