2013-02-12 84 views

回答

3

這是step選項的用途。看一看文檔:

$("#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/

+0

問題關於那個「步驟」。謝謝。 – Blender 2013-02-12 20:40:00

+1

快速演示:http://jsfiddle.net/AYHWV/ – 2013-02-12 20:40:12

+0

@vega只是在演示中擊敗了我。我也加了一個。似乎該網站今天沒有自動更新評論。 – 2013-02-12 20:41:47

2
$('#bar').animate({width: '50%'}, { 
    duration: 3000, 
    step: function(now, fx) { 
     $('#bar_pct').text(now + '%'); 
    } 
}); 
+0

謝謝@sevaor – 2013-02-12 20:47:43

相關問題