blueintegral
blueintegral

Reputation: 1271

jQuery multiple events with live()

I was under the impression that since I'm using the current version of jQuery, I could bind multiple events to live(). I'm trying to achieve a simple effect: fade down a picture when hovering, and then fade back up when mousing off of it. I have:

$(".previews").live("hover", function(){
        $(this).fadeTo('normal', .3); 
        },function(){
            $(this).fadeTo('normal', 1);
    });

From every example I've seen, this should work. Right now, when I mouse over, it fades down, but not up again.

Upvotes: 0

Views: 140

Answers (1)

Rafay
Rafay

Reputation: 31033

i dont think you can use live with hover like this,use something like

$(".previews").live({
        mouseenter:
           function()
           {
                 $(this).fadeTo('normal', .3); 
           },
        mouseleave:
           function()
           {
              $(this).fadeTo('normal', 1);
           }
       }
    );

hover is just short hand for mouseenter and mouseleave

hover: function( fnOver, fnOut ) {
return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
}

https://github.com/jquery/jquery/blob/1.4.4/src/event.js#L994-996

Upvotes: 2

Related Questions