计时器实现



function Timer(id) {
    this.container = document.getElementById(id);
}
 
Timer.prototype = {
    constructor: Timer,
    begin: function(count) {
        var container = this.container;
        setTimeout(function() {
            container.innerHTML = count > 0 ? count-- : "over";
            if(count + 1) {
                setTimeout(arguments.callee, 1000);
            }
        }, 1000);
    }
 
};

声明:Mr.xu|版权所有,违者必究|如未注明,均为原创|本网站采用BY-NC-SA协议进行授权

转载:转载请注明原文链接 - 计时器实现


Carpe Diem and Do what I like