我如何运行的jQuery的.animate函数下去吗? [英] How do i run the .animate function in jQuery forever?
本文介绍了我如何运行的jQuery的.animate函数下去吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$(this).css("left","100px");
function endless(){
$(this).animate({
left:'-=100px',
},{
easing: "linear",
duration: 5000,
complete: function() {
$(this).css('left','100px');
endless();
}
});
};
endless();
这是我试过了,但使用这种方式我不能得到的东西感动。 即时通讯使用jQuery 1.3.2。 有什么建议?
This is what I tried, but using this approach i can't get stuff moving. Im' using jQuery 1.3.2. Any Suggestions?
推荐答案
您拥有的参数来动画错误。它并不需要一个选项哈希,只是实际的选项缓解,持续时间和回调。此外,还需要照顾时,使用这
。更好地在把它作为参数传递给无尽的功能。
You have the parameters to animate wrong. It doesn't take an options hash, just the actual options for easing, duration, and a callback. Also, you need to take care when using this
. Better to pass it in as an argument to the endless function.
$(this).css("left","100px");
function endless(elem){
$(elem).animate(
{ left:'-=100px' },
"linear",
5000,
function() {
$(elem).css('left','100px');
endless(elem);
}
);
};
endless(this);
这篇关于我如何运行的jQuery的.animate函数下去吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文