答案 0 :(得分:3)
jQuery动画进度回调是在1.8中引入的:
$('#a').animate({
opacity: 1,
width: 400,
percent: 100
}, {
progress: function(animation, progress, msRemaining) {
$('#log').html(100 * progress + "%");
}
});
答案 1 :(得分:0)
我相信你可以通过使用步骤功能
来做到这一点 $('myelementid').animate({
opacity: 1,
height: 100,
percent: 100
},
{
step: function(now, fx) {
//not sure if this is 100% percent accurate
//but at least you have a value at every step of the animation
console.log( this.percent );
},
complete: function(){
//do not forget to reset percent at the end of the animaton
//so on the next animation it can be calculated from starting value of 0 again
this.percent = 0;
}
});
希望这有帮助。