javascript setInterval 在类中的应用

<SCRIPT type="text/javascript">
    function checksubmit(time,bId)
    {
        this.alltime=time;
        this.btnID=document.getElementById(bId);
        this.bvalue=document.getElementById(bId).value;
        this.Interval;
       
        this.start=function()
        {
            var _this=this;
            var fun=function(){_this.checktime();}
            _this.Interval=setInterval(fun,1000);
        }
   
        this.checktime=function()
        {       
                if (this.alltime<=0)
                {
                    this.btnID.disabled=false;
                    this.btnID.value=this.bvalue;
                    clearInterval(this.Interval);
                    delete this;
                    }
                else
                {
                    this.btnID.disabled=true;   
                    this.btnID.value=this.alltime;
                    }   
                this.alltime=this.alltime-1;
        }
    }   
       
    function submitfun(i,btnid){
        var ct=new checksubmit(i,btnid);
        ct.checktime();
        ct.start();
        return false;
    }
</SCRIPT>

你可能感兴趣的:(SetInterval)