尝试使用hover,好处是您可以在同一函数中指定 mousein 和 mouseout 事件。如果您在具体如何将您所拥有的内容应用于悬停事件方面需要任何帮助,请发表评论,我会看看我能做什么。
编辑:
好的,您网站上的代码已经有这个
//On mouse over those thumbnail
$('.zitem').hover(function() {
//Set the width and height according to the zoom percentage
width = $('.zitem').width() * zoom;
height = $('.zitem').height() * zoom;
//Move and zoom the image
$(this).find('a img').stop(false,true).animate({'width':width, 'height':height, 'top':move, 'left':move}, {duration:200});
//Display the caption
$(this).find('div.caption').stop(false,true).fadeIn(200);
},
function() {
//Reset the image
$(this).find('a img').stop(false,true).animate({'width':$('.zitem').width(), 'height':$('.zitem').height(), 'top':'0', 'left':'0'}, {duration:100});
//Hide the caption
$(this).find('div.caption').stop(false,true).fadeOut(200);
});
我将在此代码中添加两行来执行您想要的操作
//On mouse over those thumbnail
$('.zitem').hover(function() {
//Set the width and height according to the zoom percentage
width = $('.zitem').width() * zoom;
height = $('.zitem').height() * zoom;
//Move and zoom the image
$(this).find('a img').stop(false,true).animate({'width':width, 'height':height, 'top':move, 'left':move}, {duration:200});
//Change the header colour
$(this).siblings('h2').animate({'color':'#111111'},250,'linear');
//Display the caption
$(this).find('div.caption').stop(false,true).fadeIn(200);
},
function() {
//Reset the image
$(this).find('a img').stop(false,true).animate({'width':$('.zitem').width(), 'height':$('.zitem').height(), 'top':'0', 'left':'0'}, {duration:100});
//Change the header colour back
$(this).siblings('h2').animate({'color':'#EE4E07'},250,'linear');
//Hide the caption
$(this).find('div.caption').stop(false,true).fadeOut(200);
});
应该这样做