我对 jQuery .animate
无限循环中断方法的解决方案感兴趣。
$(element).mouseover(function() {
$(this).animate({ opacity: 1 }, duration, customFunc);
}).mouseout(function() {
});
现在的问题是如何打破这个循环?例如,在 mouseout
事件中?
我可以使用 setInterval
和 clearInterval
轻松完成,但是有没有办法使用 .animate
功能?
最佳答案
使用.stop方法:
我假设您想立即停止当前正在运行的动画?
$(element).mouseover(function() {
$(this).animate({ opacity: 1 }, duration, customFunc);
}).mouseout(function() {
$(this).stop();
});
关于javascript - .animate无限循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10200337/