var counter = {
init: function () {
this.creat();
},
creat: function () {
var num = this.grow();
var newArr = [];
newArr = String(num).split("");
for (var i = 0; i < newArr.length; i++) {
newArr[i] = '<span class="num' + newArr[i] + '">' + newArr[i] + '</span>';
}
$("#blue_counter").html(newArr.join(""));
this.loop();
},
loop: function () {
var self = this;
var ms = (parseInt(Math.random() * 10) + 1) * 1000;
window.setTimeout(function () {
self.creat();
}, ms);
},
grow: function () {
var dateObj = new Date();
var dateTime = dateObj.getTime();
var duringTime = dateTime - 6 * 24 * 60 * 60 * 1000;
var duringObj = new Date(duringTime);
var y = duringObj.getFullYear();
var m = duringObj.getMonth();
var d = duringObj.getDate();
var limitObj = new Date(y, m, d);
var limitTime = limitObj.getTime();
var count = parseInt((dateTime - limitTime) / 1000);
return count;
}
}
counter.init();
根据JS实现伪增长的注册人数
最新推荐文章于 2024-09-11 15:50:18 发布