我有一些缩略图设置为淡入淡出并显示帖子元数据。问题是当我将鼠标悬停在一个缩略图上时,所有缩略图都会消失。
你可以在这里看到我的意思:http://jsfiddle.net/LDs6C/10/
我怎样才能让它只有我正在徘徊的缩略图?
答案 0 :(得分:1)
您仍在匹配hover
处理程序中的所有图像和说明。您应该将选择器限制为当前缩略图,例如使用this
作为选择器上下文:
$('.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);
});
更新了小提琴here。