1

このコードを使用してdivを広げています:

$("#bar").animate({width: '50%'}, 3000);

$("#bar") div.

アドバイスをください、ありがとう!

4

2 に答える 2

3

これがstepオプションの使用目的です。ドキュメントを見てください:

http://api.jquery.com/animate/

$("#bar").animate({
    width: '50%'
}, 
{
    duration: 3000,
    step: function(now, fx){
        // update here, now is the current value
        // something like this
        $(this).text(Math.floor(now) + "%");
    }
});

http://jsfiddle.net/yFGm4/

于 2013-02-12T20:36:06.057 に答える
2
$('#bar').animate({width: '50%'}, {
    duration: 3000,
    step: function(now, fx) {
        $('#bar_pct').text(now + '%');
    }
});
于 2013-02-12T20:42:55.803 に答える