贡献我18年做技术以来的第一段发布的代码
方法:
function showNum(controlName, _num) {
var control = $(controlName);
var showRunning = 0;
var showEnd = _num;
var runningSpeed = parseInt(_num / 150); //调节越大,速度越慢
control.text("0");
var _play = setInterval(function () {
if (_num-showRunning<20) {
runningSpeed = 1;
}
control.text(showRunning);
showRunning += runningSpeed;
//if (showRunning > (showEnd * 0.95) && showRunning < showEnd) {
// setInterval(_play, 20);
// continue
//}
if (showRunning > showEnd ) {
clearInterval(_play);
}
}, 1);
}
调用:
showNum("#GlobalTop",406);
showNum("#HelloEventStoreValue",7509);
showNum("#CustomerCountTotal",6089);
showNum("#MyEventCountTotal",186);
效果: