2014-09-29 149 views

回答

2

写写关于在jQuery的.stop()方法 - http://api.jquery.com/stop/。此方法将停止正在运行的匹配元素上的动画。在你的情况下,如果在动画和css方法之前设置.stop(true,true),则悬停会正常工作。

$(document).ready(function(){ 
    $('.box').not('.box .box-lower').hover(function() { 
     $(this).find('.productsThumbWrap').stop(true, true).animate({ "margin-top": "+=108px" }, "normal"); 
     $(this).find('.productsThumbWrap img').stop(true, true).css({opacity:1,'transition': 'opacity 0.3s ease 0.35s'}); 
    }, function(){ 
     $(this).find('.productsThumbWrap').stop(true, true).css({'margin-top': '92px'}); 
     $(this).find('.productsThumbWrap img').stop(true, true).css({opacity:0,'transition':'none'}); 
    }); 
});