手记

js计时器及补0

//计时器
        function jstimer(){
            var time = 0;
            setInterval(() => {
                time++;
                var min=Math.floor(time%3600);
                $('#interview_time').html('面试时长:'+zero(Math.floor(time/3600)) + ":" + zero(Math.floor(min/60)) + ":"+ zero(time%60));
            }, 1000);
        }
       
        //补零
        function zero(time){
            if( time<10 ){
                time = '0'+time;
            }
            return time;
        }


1人推荐
随时随地看视频
慕课网APP