开发者

jquery - thumbnails fading altogether instead of only the one I have my mouse over

开发者 https://www.devze.com 2023-02-10 06:11 出处:网络
I have a few thumbnails set up to fade on hover and reveal the post metadata. The problem is when I hover over one thumbnail, all of them fade.

I have a few thumbnails set up to fade on hover and reveal the post metadata. The problem is when I hover over one thumbnail, all of them fade.

You can see what I me开发者_开发问答an here: http://jsfiddle.net/LDs6C/10/

How can I make it so only the thumbnail I'm hovering over fades?


You're still matching all the images and descriptions in your hover handler. You should restrict the selectors to the current thumbnail, e.g. by using this as the selector context:

$('.thumbnail').hover(function() {
    $('img', this).stop(true, true).fadeTo(400, 0.2);
    $('.description', this).stop(true, true).fadeIn(400);
}, function() {
    $('img', this).stop(true, true).fadeTo(400, 1);
    $('.description', this).stop(true, true).fadeOut(400);
});

Updated fiddle here.

0

精彩评论

暂无评论...
验证码 换一张
取 消