Search code examples
jquery-animateprogress

jQuery animate() show the percent of the animation progress


With that following snippet: http://jsfiddle.net/sylouuu/V7a3Y/2/ I would like to show the % progress in #log of the animation from 0% to 100%, the 100% is easy with the callback...

Is it possible to do that?

Regards


Solution

  • The jQuery animate progress callback was introduced in 1.8:

    $('#a').animate({
        opacity: 1,
        width: 400,
        percent: 100
    }, {
        progress: function(animation, progress, msRemaining) {
            $('#log').html(100 * progress + "%");
        }
    });