我正在尝试使用jquery animate在我的html上运行字幕运行文本。以下是我的代码:
$(document).ready(function() {
$('.scroll').animate({
right: $(document).width() // animates right value from the original -200px(from css) to the documents width(ie if elements right value = the document width, then element is off screen)
}, 3000);
});
.scroll {
position: absolute;
right: -200px;
width: 200px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="scroll">This text be scrollin'!</div>
以下是演示: https://jsfiddle.net/y9hvr9fa/
问题是,它只运行一次。我可以知道如何让它在无限循环中运行吗?