2010-03-21 39 views
1

如何在右图像为+ 400px时添加if语句,然后将动画恢复为-400px ...当鼠标悬停在正确的图像上时?jquery if语句动画返回

$('#left img').mouseenter(function() { 
    $('#right img').animate({ 
    left: '+=400px' 
    }, 700);        

}); 
$('#right img').mouseenter(function() { 
    $('#left img').animate({ 
    left: '-=400px' 
    }, 700); 

}); 

this类似的东西。 (这两个网站上的主图像)

回答

2

为什么根本不使用:mouseleave

$("#left img").mouseenter(function(){ 
    //+400 
    }).mouseleave(function(){ 
     //-400 
    }); 

Peraphs是相同的鼠标悬停/鼠标移开和悬停

+0

感谢您的时间 – user295292

+0

没有问题的兄弟! ;-) –