如何在jQuery中连续循环播放动画? [英] How can I loop an animation continuously in jQuery?
本文介绍了如何在jQuery中连续循环播放动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要知道如何无限循环这个动画。它是一个文本滚动动画,我需要它在完成后重复。
I need to know how to infinitely loop this animation. It is a text scroll animation and I need it to repeat after it's finished.
这是jQuery:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".boxtext").ready(function(){
$(".boxtext").animate({bottom:"600px"},50000);
});
});
</script>
这是.boxtext的CSS
Here is the CSS for ".boxtext"
.boxtext {
position:absolute;
bottom:-300px;
width:470px;
height:310px;
font-size:25px;
font-family:trajan pro;
color:white;
}
推荐答案
使它成为一个功能并拥有它将自己称为回调:
Make it a function and have it call itself as a callback:
$(document).ready(function(){
scroll();
}
function scroll() {
$(".boxtext").css("bottom", "-300px");
$(".boxtext").animate({bottom:"600px"}, 50000, scroll);
}
请记住,这不会很流畅。
Keep in mind, this won't be very fluid.
编辑:我之前没有想过。我的错误。
I wasn't thinking earlier. My mistake.
这篇关于如何在jQuery中连续循环播放动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文