I was under the impression that since I'm using the current version of jQuery, I could bind multiple events to liv开发者_如何学编程e(). 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.
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
精彩评论