Pam
Pam

Reputation: 77

How to repeat animation on complete using jQuery's animate() function?

Here's my code. How to get the animation to repeat every time it completes?

$('img.balloon').animate({
     bottom : '100%'
}, 4000, 'linear', function() {
     // on complete repeat but how?
});

Upvotes: 2

Views: 878

Answers (1)

Paul
Paul

Reputation: 141829

(function doAnim(){
    $('img.balloon').css('bottom', '-20px').animate({
         bottom : '100%'
    }, 4000, 'linear',
    doAnim);
})();

Upvotes: 3

Related Questions