我目前有以下代码:
$("ol#homePortfolio li img").fadeTo("slow", 1.0);
$("ol#homePortfolio li img").hover(
function() {
$("ol#homePortfolio li img").fadeTo("slow", 0.8);
},
function() {
$("ol#homePortfolio li img").fadeTo("slow", 1.0);
}
);
Run Code Online (Sandbox Code Playgroud)
但是,当我将图像悬停在图像上多次fadeIn并fadeOut继续进行时,如何应用停止以便它只发生一次?
T.J*_*der 27
你可能正在寻找这个stop功能.(jquery.com今天遇到问题,这里是Google缓存副本的链接.)stop停止当前正在进行的任何动画.
只需在开始动画之前调用它,停止该元素上的任何先前动画:
$("ol#homePortfolio li img").stop().fadeTo("slow", 0.8);
// ^----
Run Code Online (Sandbox Code Playgroud)
你想要稍微玩一下(我不做很多可能重叠的动画),在中间停止一些动画可能意味着你需要确保将元素重置为已知状态.或者,使用jumpToEnd标志:
$("ol#homePortfolio li img").stop(false, true).fadeTo("slow", 0.8);
// ^ ^-- true = jump to the end of the animation
// |--------- false = don't clear the queue (you may
// want true here, to clear it)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12142 次 |
| 最近记录: |