jQuery API

.live()

.live( events, handler(eventObject) ) Returns: jQuery

Description: Attach an event handler for all elements which match the current selector, now and in the future.

  • version added: 1.3.live( events, handler(eventObject) )

    eventsA string containing a JavaScript event type, such as "click" or "keydown." As of jQuery 1.4 the string can contain multiple, space-separated event types or custom event names.

    handler(eventObject)A function to execute at the time the event is triggered.

  • version added: 1.4.live( events, data, handler(eventObject) )

    eventsA string containing a JavaScript event type, such as "click" or "keydown." As of jQuery 1.4 the string can contain multiple, space-separated event types or custom event names.

    dataA map of data that will be passed to the event handler.

    handler(eventObject)A function to execute at the time the event is triggered.

  • version added: 1.4.3.live( events-map )

    events-mapA map of one or more JavaScript event types and functions to execute for them.

As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers. Users of older versions of jQuery should use .delegate() in preference to .live().

This method provides a means to attach delegated event handlers to the document element of a page, which simplifies the use of event handlers when content is dynamically added to a page. See the discussion of direct versus delegated events in the .on() method for more information.

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

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

The events argument can either be a space-separated list of event type names and optional namespaces, or an event-map of event names strings and handlers. The data argument is optional and can be omitted. For example, the following three method calls are functionally equivalent (but see below for more effective and performant ways to attach delegated event handlers):

$("a.offsite").live("click", function(){ alert("Goodbye!"); });                // jQuery 1.3+
$(document).delegate("a.offsite", "click", function(){ alert("Goodbye!"); });  // jQuery 1.4.3+
$(document).on("click", "a.offsite", function(){ alert("Goodbye!"); });        // jQuery 1.7+

Use of the .live() method is no longer recommended since later versions of jQuery offer better methods that do not have its drawbacks. In particular, the following issues arise with the use of .live():

  • jQuery attempts to retrieve the elements specified by the selector before calling the .live() method, which may be time-consuming on large documents.
  • Chaining methods is not supported. For example, $("a").find(".offsite, .external").live( ... ); is not valid and does not work as expected.
  • Since all .live() events are attached at the document element, events take the longest and slowest possible path before they are handled.
  • On mobile iOS (iPhone, iPad and iPod Touch) the click event does not bubble to the document body for most elements and cannot be used with .live() without applying one of the following workarounds:
    1. Use natively clickable elements such as a or button, as both of these do bubble to document.
    2. Use .on() or .delegate() attached to an element below the level of document.body, since mobile iOS does bubble within the body.
    3. Apply the CSS style cursor:pointer to the element that needs to bubble clicks (or a parent including document.documentElement). Note however, this will disable copy\paste on the element and cause it to be highlighted when touched.
  • Calling event.stopPropagation() in the event handler is ineffective in stopping event handlers attached lower in the document; the event has already propagated to document.
  • The .live() method interacts with other event methods in ways that can be surprising, e.g., $(document).unbind("click") removes all click handlers attached by any call to .live()!

For pages still using .live(), this list of version-specific differences may be helpful:

  • Before jQuery 1.7, to stop further handlers from executing after one bound using .live(), the handler must return false. Calling .stopPropagation() will not accomplish this.
  • As of jQuery 1.4 the .live() method supports custom events as well as all JavaScript events that bubble. It also supports certain events that don't bubble, including change, submit, focus and blur.
  • In jQuery 1.3.x only the following JavaScript events could be bound: click, dblclick, keydown, keypress, keyup, mousedown, mousemove, mouseout, mouseover, and mouseup.

Examples:

Example: Click a paragraph to add another. Note that .live() binds the click event to all paragraphs - even new ones.

<!DOCTYPE html>
<html>
<head>
  <style>
  p { background:yellow; font-weight:bold; cursor:pointer;
      padding:5px; }
  p.over { background: #ccc; }
  span { color:red; }
  </style>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
  <p>Click me!</p>

  <span></span>
<script>
$("p").live("click", function(){
  $(this).after("<p>Another paragraph!</p>");
});
</script>

</body>
</html>

Demo:

Example: Cancel a default action and prevent it from bubbling up by returning false.

$("a").live("click", function() { return false; })

Example: Cancel only the default action by using the preventDefault method.

$("a").live("click", function(event){
  event.preventDefault();
});

Example: Bind custom events with .live().

<!DOCTYPE html>
<html>
<head>
  <style>
  p { color:red; }
  span { color:blue; }
  </style>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
  
  <p>Has an attached custom event.</p>
  <button>Trigger custom event</button>
  <span style="display:none;"></span>
  
<script>
$("p").live("myCustomEvent", function(e, myName, myValue) {
  $(this).text("Hi there!");
  $("span").stop().css("opacity", 1)
           .text("myName = " + myName)
           .fadeIn(30).fadeOut(1000);
});
$("button").click(function () {
  $("p").trigger("myCustomEvent");
});
</script>

</body>
</html>

Demo:

Example: Use a map to bind multiple live event handlers. Note that .live() calls the click, mouseover, and mouseout event handlers for all paragraphs--even new ones.

<!DOCTYPE html>
<html>
<head>
  <style>
  p { background:yellow; font-weight:bold; cursor:pointer; padding:5px; }
  p.over { background: #ccc; }
  span { color:red; }
  </style>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
  
  <p>Click me!</p>
  <span></span>
  
<script>
$("p").live({
  click: function() {
    $(this).after("<p>Another paragraph!</p>");
  },
  mouseover: function() {
    $(this).addClass("over");
  },
  mouseout: function() {
    $(this).removeClass("over");
  }
});
</script>

</body>
</html>

Demo:

Support and Contributions

Need help with .live() or have a question about it? Visit the jQuery Forum or the #jquery channel on irc.freenode.net.

Think you've discovered a jQuery bug related to .live()? Report it to the jQuery core team.

Found a problem with this documentation? Report it on the GitHub issue tracker

  • http://ryanparman.com Ryan Parman

    What arguments are passed back to the callback handler? In JQuery it seemed to be event and selector, but in 1.4 it seems to only be event, where selector is available by digging around.

  • http://twitter.com/bigredswitch bigredswitch

    what about selector driven live events, as in the semi-eponymous livequery

    that is:
    $(‘.foo’).live(function(){
    // do something
    })

    • andrew

      yeah, what about this? as far as i can tell, that doesn’t work. and you can’t give it null as the event type, sadly.

  • Anonymous

    The documentation states that .stopPropagation() will not have the intended effect with live-bound events, but I’ve found that by checking .isPropagationStopped() you can get around this.I have nothing against returning false from my functions but if for some reason you like for the return type of your functions to be something else, you can currently use .isPropagationStopped() correctly in the binding on the ancestor element that you do not wish to be triggered.Does anybody know if this functionality is intended, something that we can rely on, and recommended?

  • Anonymous

    why does .live() not work when its being called on a cached DOM element like :var myDiv = $(“”).addClass(“justATest”).html(someCahchedHTML)myDiv.live(“click”, function(){alert(“this will not be fired”)})

    • http://k12th.ya.ru/ Guest

      Because .live() should be called on selectors, not on the elements. Freshly created and even not yet attached nodes have not selectors

      • Anonymous

        Thanks, and how about a cached selector?

        like
        var allMylinks = $(“a”);
        allMylinks.live(“click”, function(){
        console.log(“logs nothing”)
        })

  • buymeasoda

    Hi,

    Could you please update the docs and examples to include details of the new ability to use a context with the live() event.

    It was mentioned in the release notes during 14 days of jQuery, but I can't see it presented here in any detail.

    From: http://jquery14.com/day-01/jquery-14

    live/die now work with context (Commit)

    You can now specify a context to the selector that will be used to bind a live event. If you do, only elements under that context will be bound. While the elements themselves do not need to exist when you create the live event, the context must exist.

  • Remus

    When using live() with the “change” event, if the initial value of the element bound to is nothing (element is empty) and you type in a value, the event does not trigger as it should. It only triggers if there is an initial value in there or if the value is changing (duh!) but not when the value is empty and you put a value in for the first time.

    Is this a bug or should I use a different event to capture even the first “change”, from empty to a non-empty value?

  • Anonymous

    Does .Live() support namespaced events? I’m not having problems when I .bind(“click.namespace”, handler), but I cant seem to get the same thing to work with .live(“click.namespace”, handler). I don’t know if this is a bug or just not supported. Thanks!

  • Anonymous

    Since $(selector, context) is implemented with $(selector).find(context), I assume $(selector).find(context).live() will work. Am I correct?

    • http://www.learningjquery.com/ Karl Swedberg

      Unfortunately, no. The .live() method doesn’t use the jQuery collection created by the selector for anything; it only uses the selector as the event target.

      • Anonymous

        Hmm… I am using $(selector).find(context).live() in my app and it is working. Should I not use it? Thanks.

        • http://www.learningjquery.com/ Karl Swedberg

          Actually, you can’t find a context within a selector. That’s sort of backwards. The reason it appears to be working with .live() is that .live() is simply ignoring .find(‘context).

          • Anonymous

            Sorry I mistakenly switched the “selector” and “context” in my original post. Here’s what I meant. $(selector, context) is implemented with $(context).find(selector). See:
            http://api.jquery.com/jquery/#selector-context

            So that’s why $(context).find(selector).live() works. Tell me if I am still wrong. Thanks!

          • http://www.learningjquery.com/ Karl Swedberg

            Sorry, but you’re still wrong. Above you’ll find that one of the caveats says this:
            “DOM traversal methods are not fully supported for finding elements to send to .live(). Rather, the .live() method should always be called directly after a selector, as in the example above.”

          • Anonymous

            Yet, http://api.jquery.com/jquery/#selector-context says:

            “Internally, selector context is implemented with the .find() method, so $(‘span’, this) is equivalent to $(this).find(‘span’).”

          • http://www.learningjquery.com/ Karl Swedberg

            Right, but .live() is an exception.

          • http://diyism.com diyism

            I think you are right, i even do this:

            $($(window.parent.document).find(‘.gtc-translation iframe’)[0].contentWindow.document)
            .find(‘#goog-gtc-prevlink’).live(‘mousedown’, function(){alert(“hello”);});

            in “mason script for google translator toolkit”.

        • Chris C

          It will work, but the elements that live() are applied to will not be limited to those that are children of $(selector). For example:

          $(‘#parentElt’).find(‘.myClass’).live(‘click’ function() {alert(‘x’);})

          Clicking on ANY element with a class of “.myClass” will cause the alert to appear: not just those elements that are a child of “#parentElt”.

          Solution:

          $(‘#parentElt .myClass’).live(‘click’ function() {alert(‘x’);})

          • Chris C

            This has all been covered in the existing thread, I missed it as I didn’t load the other comments first :)

  • landonspringer

    Hopefully this will save someone the 30 minutes it cost me…

    The .live() function will stop propagation if you return false, but this won't work for other bindings on $(document). You have to e.stopImmediatePropagation() to prevent other bindings on $(document) from firing. Example:

    $(document).bind('click', function() {
    alert('document clicked');
    });

    $('.some-selector').live('click', function(e) {
    e.stopImmediatePropagation();
    return false;
    });

  • Wuwu

    Im missing a clear list of all supported events.

    • http://www.learningjquery.com/ Karl Swedberg

      All of them are supported now.

      * As of jQuery 1.4 the .live() method supports custom events as well as all JavaScript events. As of jQuery 1.4.1 even focus and blur work with live (mapping to the more appropriate, bubbling, events focusin and focusout).
      * As of jQuery 1.4.1 the hover event can be specified (mapping to “mouseenter mouseleave”).

      • iys

        Hover event in jQuery 1.4.2 seems to be mapped “mouseover” and “mouseout” rather than “mouseenter” and “mouseleave”…

        IE8 and FF3.6

      • Anonymous

        .live() still does not work on load events, as of 1.4.2.

  • Anonymous

    I had hoped that in your last example( … “can bind custom events too”) that you would have demonstrated how to trigger the live method using values for myName and myValue. I have a similar problem that I am working on and I am having trouble passing values to the live method using a custom event.

    • Anonymous

      Sorry, was able to find a link under the trigger documentation. I see that it would be coded as follows: $(“p”).trigger(“myCustomEvent”, ['value1', 'value2']);

      • david

        How can I know within Live(click) funcion which button is click?

        function Handler(event) {
        event.preventDefault();
        this.style.backgroundColor = '#' + '05e';
        var text_sel;
        text_sel = ” your sel ” + //How can I know here wich button is click
        alert(text_sel);
        }
        $(“input[name^='AnsBut']“).live(“click”, { msg: “this is the text” }, Handler);

  • Triple3

    Is there any way to UNBIND something attached with the live method? I’m actually using live to attach an event but later want to remove the event but it doesn’t seem to remove. I’m not sure if it’s removing and the live previously called to add it is readding it or it simply won’t remove.

    Thanks

  • http://twitter.com/jasonedelman Jason Edelman

    As of 1.4.2, this is broken with custom events. Try the following:

    $(function(){
    $(document).live('something', function() { console.log('LIVE'); });
    $(document).trigger('something');

    $(document).bind('other', function() { console.log('BIND'); });
    $(document).trigger('other');
    });

    Only “BIND” will show up in your console: http://jsbin.com/erofi. WTF

  • http://tekkie.flashbit.net/ Ain Tohvri

    Looks to me that live() is not working with change event on IE7. Any comments?

  • http://profiles.yahoo.com/u/ZE4JAMQ6SZHZYORMDHRXQL33VU TaberJ

    I'm having trouble distinguishing the difference between these calls other than what Karl mentioned; that the first selector becomes the target in the callback function. These all seem to give the same results.

    $('#list').find('a.button').live('click', {test: 'sausages'}, MyObj.btnClicked);

    $('#list a.button').live('click', {test: 'sausages'}, MyObj.btnClicked);

    $('a.button', $('#list')[0]).live('click', {test: 'sausages'}, MyObj.btnClicked);

    and even:

    $('#list', $('#container')).find('a.button').live('click', {test: 'sausages'}, MyObj.btnClicked);

    MyObj = {

    btnClicked: function(e) {
    alert($(this).html()); // alerts the innerHtml of the clicked link
    }
    }

  • http://twitter.com/matiaslarsson Matias Larsson

    It seems there are some issues in IE8 and jQuery 1.4.2 regarding live() and drag'n'drop events;

    1. IE8 doesn't throw “dragend” events when using live() as the other browsers. It does work when using bind() though.

    2. IE8 doesn't allow drops when using live() on the drop target, the other browsers do. It does work when using bind() though.

    Will report this in the bug tracker if not already reported. (Test case available at http://homepage.mac.com/matias/jquery/bug-live-… )

    • http://twitter.com/sv1l Sylvain DETHIER

      I’m experiencing the same bugs: the events for “dropable” elements (dragenter, dragover, dragleave, drag) are not triggered by IE8 (not tested for the previous versions sorry); though it works on all other major browsers (FF, Chrome, Safari, Opera 10.60 doesn’t support native ‘drag and drop’) and on IE9 preview (v.9.0.7916.6000)

  • Dima

    It appears that $(selector).live() has to actually evaluate the selector and perform a DOM query before attaching the handler to the root, which seems kinda wasteful, especially when the selector is complex, and/or matches many elements, since, the result of the query is nor really needed.
    Wouldn't it be better and more useful if the semantics was more along the lines of
    $(context).live(selector, event, handler), so that one could do something like
    $(document).live(“.button”, “click”, handleClick) without having to find all the buttons on the page?

    For the time being, I find it better to just use
    $(document).bind('click', function(e) { if($(e.target).is(.button)) handleClick(e); });
    instead of .live() for the effectiveness.

    • http://www.learningjquery.com/ Karl Swedberg

      Maybe sometimes. That's why we have the .delegate() method.

      • Dima

        So, what exactly is the advantage of .live() over .delegate()?
        Or rather when exactly is it advantageous to use .live() rather than .delegate()?

        • http://twitter.com/trevorburnham Trevor Burnham

          .live() just gives you a nicer syntax. .delegate() is always more efficient.

    • http://twitter.com/andreiashu Andrei Simion

      Thanks Dima,
      Your way of binding event helped a lot in a page where normally I would have had to add hundreds of event listeners.

  • http://stylr.nl Robin

    Live doesn't seem to work on a newly created anchor tag. Look at my example here: http://jsbin.com/udera/

    If I use bind, it works perfectly… What's the big difference?

    • ECELonghorn

      I never considered doing this so it peaked my interest and I looked into it. The problem is your example.

      What is the semantic meaning of what you are trying to achieve? You create an anchor then attach a live query to it. What future elements would you want it to add live events to… any constructed anchor tags, every anchor tag, every element? Bottomline, because of this ambiguity, there is no universal way to handle the case so live does nothing.

      Every jQuery object has a property called selector. If you create the element from the constructor shorthand it leaves this as an empty string. If you did like $('.foo') it would equal “.foo” etc.
      Live uses this property (via magic) to attach the event to all existing and newly created objects. When it is passes objects with no selector property, it doesn't know how to interpret what you want to happen so it does nothing.
      Bind however, just needs to have an object and it attaches the event directly to the object.

      In you case there is no benefit to use live… just use bind.

      If it looks like a bug etc… then most likely you just don't understand what is going on. :)

  • http://twitter.com/5minuteargument Five Minute Argument

    I was under the impression that .live() events would progagate. However, when I use this:

    $('*').live('click', function() {
    console.log(this);
    });

    and click on an li nested inside a ul (in turn inside body, html), I only see a single log line for the original li. What gives?

  • Curious

    I am wondering whether there is a remedy for IE8 not accepting “change” within “live()”. Do I need to go back to “livequery”?

    • http://twitter.com/jleveille Jason Leveille

      I had issues in IE8 with 1.4.2 and live/change as well. I switched to using delegate instead of live and my problems went away.

      • vol7ron

        I wish you would elaborate on how you got delegate to work.

        I'm trying to apply events after an object is created.
        Something like the example in my post: applying an event to the datepicker's next/prev click. (Datepicker elements are recreated on the next/prev click). Nothing has worked in IE7. The only things that work are live()/delegate() in Firefox.

        Would sure like an example.

  • C.L. Moffatt

    Will there be any attempt to add the $(document).ready as one of the .live() events? This would be really helpful for AJAX.NET developers

  • Foo

    $('input').not('.no_change').live('change', function(){..});

    Live in combination with not doen't seem to work here.

    • http://twitter.com/gijsvanzon Gijs van Zon

      You should use delegate instead. Delegate works with .not, .parent, .children, etc.

    • http://www.learningjquery.com/ Karl Swedberg

      That's right. Please see the Caveats section above.

    • chrisovenden

      Haven't tried it but what about $(“input:not(.no_change)”)?

  • http://twitter.com/gijsvanzon Gijs van Zon

    Is it possible to bind a function on an element that is just created. So for instance:

    $('.someClass').live(function(){
    alert('element entered dom');
    });

  • Brian

    Soooo… .live() on the submit event doesn't work in IE8 (maybe other IE versions as well)?

  • Zack

    Using .live('change') would, perhaps, cause infinite looping, since we are applying an event to a change, then that event is being applied to that change, etc.

  • http://spoonmeiser.myvidoop.com/ Oliver Jeeves

    It's not entirely clear from the documentation here, but I guess that providing a context only works if the elements selected by the context already exist and don't get destroyed.

    That is:

    var ctx = $('#my-wrapper');
    $('.my-clickable', ctx).live('click', some_function);

    Won't work if #my-wrapper doesn't at this point in time, or is removed and re-created later.

    Is there likely to be performance issues if using, say, a class selector (which is slow anyway, if selecting elements from a large document) with an event that is likely to fire often, such as mouseover?

    • Henk

      I just discovered this issue too, you can't bind an event to an element that doesn't exist yet. The workaround I'll probably apply is put an empty element matching the selector and apply the live() to that, the contents of the div are overwritten anyways.

      (specifically, this issue is about setting a hover and click handler on the suggestions from an autosuggest box. The first implementation added those handlers inline each time the autosuggestions were generated.)

    • Jhyjh

      vch

  • Nick

    Not sure if this might be a bug or is due to the traversing. but live doesn’t execute when bind to a set of elements like so:
    jQuery.each(elementGroup, function(index,elm){
    jQuery(elm).live(‘click’, function(){ // do something });
    }

    • James

      Why not just use bind there? The pattern for using live should be:

      $('some-selector-string').live(…)

      You shouldn't expect anything else to work: “the .live() method should always be called directly after a selector, as in the example above.”

  • S Neu

    In the demo-example above just use the “dbclick”-event instead of the “click”, and it’s not working anymore (Firefox 3.5.13). Is there a special reason for this?

    • Anonymous

      Its ‘dblclick’

  • vol7ron

    I thought the purpose of live was to use it for late binding.

    Apparently this works in FF, but not IE.
    See what happens when trying to add a class to parts the datepicker after next/prev are clicked: http://jsfiddle.net/XNqp3/1/

    Note: next/prev creates new elements for the datepicker internals, hence the need for re-applying a class. Additionally, datepicker does not offer an afterCreate callback.

  • Rtpmatt

    I just found in some code that I am fixing a $(s).find(something) and the code actually worked just fine. Removing the find entirely broke it, but when I moved what was into the find into the first selector it worked just fine. Given the first caveat (and how I know .live works) I am not sure why this happened. I have not had a chance to look at the jQuery source to see why this is yet. Anybody have any ideas? It was using jquery 1.4.2

    • Rtpmatt

      could it be that when the selector is a string, the find is just concated onto it?

  • Mihai Constantinescu

    i also have an issue in IE8 with 1.4.2 and live/change. I tested also with delegate but it's not working.

    $(“.something”).live('change', function(){
    $('.class_name').removeClass('my_class');
    });

    any idea?

    • Suryakumar Kondpalli

      I too am facing same issue.
      I get the event.type as “beforedeactivate” whereas it works fine in Chrome.

      Regards
      Surya

  • Osman1981

    $('img.unsel', $('div#fotos_list')).live('click',function(){show_big(this)})
    ……
    $('img.unsel', $('div#fotos_list')).trigger('click')

    why Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 ( .NET CLR 3.5.30729) say that: “abc.trigger is not a function”

  • paran0id

    can anyone help….I need to incorporate the live() function into the following

    $(“input[name^='cost']“).sum(“keyup”, “#result”);

    but can't figure out how to do it

  • Rob Steward

    If you want to unbind an event that was bound using .live(), you should call .die() on the jQuery object:

    $('img').live('click', function() { … } );
    ….
    $('img').die('click')

    See http://api.jquery.com/die/ for more info.

  • Aptrik

    I'm want to use 3rd party JQuery Code. It's a tooltip. When mouseover an image i can show bigger picture with Tooltip.

    I can use with everything this tooltip but, i can't access created elements with this tooltip.

    code like this:

    $(“img[src*='_s.jpg']“).thumbPopup({

    imgSmallFlag: “_s”,

    imgLargeFlag: “_s”

    });

    Can anybody help me?

    Thanks…

  • Nathan

    “In jQuery 1.3.x only the following JavaScript events (in addition to custom events) could be bound with .live(): click, dblclick, keydown, keypress, keyup, mousedown, mousemove, mouseout, mouseover, and mouseup.”

    Submit works too… tested in jQuery 1.3.2.

    • http://www.learningjquery.com/ Karl Swedberg

      Not reliably across all browsers (notably IE)

  • chrisr

    i would like to live on the addition of the element to the DOM so that I may adjust its attributes, is that possible?

  • karnash

    if i dont wanna a event.. :S how added a live.. .?? for instance when i added a flexigrid function to a dinamic table like

  • robwgibbons

    Are there any plans to add support for object-literal multiple event binding? I often use bind() to attach several events at once in the literal pattern. Is there a technical reason this hasn't been included?

  • TP

    Note for IE
    If you try to assign a live event handler on an element that doesn't exist, then any other live event handlers will not work, you will receive no errors, either.

  • Suryakumar Kondpalli

    I too am facing same issue.
    I get the event.type as “beforedeactivate” whereas it works fine in Chrome.

    Regards
    Surya

  • Bleh

    is this function supposed to be pronounced “liv” or “lyve”

    • dk

      Since the opposite function is die(), I'd say “liv”.

    • http://dan.cx/ Daniel15

      I'd say “lyve”. Elements that are added in the future get the event handler, so it's a “live” list of sorts.

  • dk

    Since the opposite function is die(), I'd say “liv”.

  • Richardacre

    I have an input type=file and the following
    $(“#foo”).change( … )
    calls the function as soon as it changes but this
    $(“#foo”).live(“change”,…)
    doesnt, effectively making it equivelant to blur().
    This is only with IE. Will test other browsers :)

  • yanibie

    hi :) ,
    does anybody knows why does the event.data comes up undefind?
    I get no errors on firebug, event is raised perfectly, but no event.data
    i am using this code:
    $(“…”).live(“drop”,
    function(event){

    try{var sData = event.data;

    //

    }
    catch(ex)
    {console.log(ex.message);}
    finally
    {
    return false;
    }
    }

  • Muiter

    Can someone help me out with changing my code to the .live event? I can't get it to work.

    $(function() {

    $(“.dblclick”).editable(“includes/js/save_to_db.php”, {
    indicator : “<img src=”images/icon/indicator.gif”>”,
    tooltip : “Klik om te bewerken”,
    event : “dblclick”,
    style : “inherit”
    });
    });

  • http://twitter.com/biinjo Robin van Baalen

    I don't want to be too hasty in my conclusions, but it looks like a bug, smells like a bug and acts like a bug….

    Just to be sure I edited my jsbin.com example. Now it uses jQuery 1.4.2 instead of just “jQuery latest”. Thisway we can establish if it is a 1.4.2 bug or not. New link: http://jsbin.com/udera/5

  • http://twitter.com/hdocsek Hans Docsek

    Have a look at the first bullet in the Caveats section above.
    It says “… the .live() method should always be called directly after a selector”.
    Your example should work if you select the anchor explicitly after creating it.

  • Rob Steward

    No problem! Actually, I'm surprised there is no mention of it on this page. Maybe a mod could edit the article?

  • http://www.learningjquery.com/ Karl Swedberg

    done.