我正在尝试实现一个带有无限循环的 jQuery 函数来为 div 制作动画。我不知道该怎么做。这是我的代码:
$(document).ready(function () {
$('#divers').animate({
'margin-top': '90px'
}, 6000).animate({
'margin-top': '40px'
}, 6000);
});
最佳答案
将执行完整动画的代码放入函数中,然后将该函数作为回调参数传递给最后一个动画。类似...
$(document).ready(function() {
function animateDivers() {
$('#divers').animate(
{'margin-top':'90px'}
,6000
)
.animate(
{'margin-top':'40px'}
,6000
,animateDivers //callback the function, to restart animation cycle
);
}
animateDivers(); //call, to start the animation
});
关于jquery - 如何循环播放 jQuery div 动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13367036/