JavaScript&Platform/jQuery
[jQuery] 숫자 자동 증가 animation
비니미니파파
2014. 12. 11. 09:50
구글링으로 찾은 예제를 조금 수정하였다.
다음에 재활용하기 위해 function 으로 만들어 보았다.
// 숫자 자동증가
// ex) autoIncrementVal( obj, val, durationVal );
// autoIncrementVal( "#testVal", 95, 2500 );
var autoIncrementVal = function(obj, val, durationVal)
{
$({someValue: 0}).animate({someValue: val}, {
duration: durationVal,
easing:'swing', // can be anything
step: function() { // called on every step
// Update the element's text with rounded-up value:
$(obj).text(Math.ceil(this.someValue));
}
});
}