How can I loop an animation continuously in jQuery?

前端 未结 9 1227
长情又很酷
长情又很酷 2020-12-01 14:52

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.

Here is the jQuery:



        
9条回答
  •  感动是毒
    2020-12-01 15:18

    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.

    EDIT: I wasn't thinking earlier. My mistake.

提交回复
热议问题