【发布时间】:2012-09-03 03:12:44
【问题描述】:
我在一个页面上有许多人的照片,我想在鼠标悬停时显示一个人的备用照片,并在鼠标移出时将照片恢复为默认值。我还希望在有人单击照片以查看其个人资料(显示在侧边栏上)时显示备用照片。当有人点击其他人时,将为该人显示默认照片。我无法结合点击和悬停事件来实现这一点。
这是我目前所拥有的。我在那里聚会,但是这不会将以前查看的个人资料图片恢复为其默认照片。当点击不同的个人资料图片时,如何从以前查看的个人资料中删除点击事件?
$('.rollover').click(function() {
$(this).unbind('mouseout');
}).mouseover(function() {
img_src = $(this).attr('src'); //grab original image
new_src = $(this).attr('rel'); //grab rollover image
$(this).attr('src', new_src); //swap images
$(this).attr('rel', img_src); //swap images
}).mouseout(function() {
$(this).attr('src', img_src); //swap images
$(this).attr('rel', new_src); //swap images
});
提前致谢。
【问题讨论】:
标签: jquery