jquerylivejquery-1.4

jquery live hover


I'm using the following jquery code to show a contextual delete button only for table rows we are hovering with our mouse. This works but not for rows that have been added with js/ajax on the fly...

Is there a way to make this work with live events?

$("table tr").hover(
  function () {},
  function () {}
);

Solution

  • jQuery 1.4.1 now supports "hover" for live() events, but only with one event handler function:

    $("table tr").live("hover",
    
    function () {
    
    });
    

    Alternatively, you can provide two functions, one for mouseenter and one for mouseleave:

    $("table tr").live({
        mouseenter: function () {
    
        },
        mouseleave: function () {
    
        }
    });