Jquery动画重复代码

时间:2011-03-15 12:52:25

标签: jquery html html5 jquery-animate

我已经制作了代码,但我想让它重复执行,直到用户在页面上。

这是我的代码---

                   $(document).ready(

                     function animate() {
                          $('div.lightining').stop().animate({
                            backgroundColor: '#789'
                          }, 1050, 'linear', function() { });
                     }

                     function () { $('div.lightining').cycle(animate()); }

                   );

我希望脚本在完成后重复。 有人得到任何实现这一点的想法。请帮帮我!

提前致谢!

2 个答案:

答案 0 :(得分:1)

           $(document).ready( function() {


             function animate() {
                  $('div.lightining').stop().animate({
                    backgroundColor: '#789'
                  }, 1050, 'linear', function() {  animate(); });
             }

           animate();

           });

答案 1 :(得分:0)

下面的代码将连续循环播放动画

属性是动画

的属性

将值设定为

的动画

持续时间。

将这些设置为您想要的任何内容。

动画完成后,回调再次调用动画。

 $(document).ready(function(){

    animate();

});

function animate(){

    $(".lightning").animate({
        attribute:value
    },duration,function(){
        animate();
    });

}

不确定你对页面部分的意思。你必须在那里澄清。 如果我是正确的,你不能在没有插件的情况下为背景颜色制作动画。