倒计时demo

倒计时demo

<div class="countDown"></div>

;(function(){
  var loading = (function(timer,callback){
    var ele = document.querySelectorAll(".countDown")[0],
      t = 1000,
      fn = function (){
        ele.innerHTML = timer / t;
        timer -= t;
        if(timer <= 1){
          callback && callback();
          clearInterval(hand);
        }
      };
      hand = setInterval(fn,t);
  })(3000);    
}())

 

posted @ 2017-05-10 22:54  莫问、前程  阅读(111)  评论(0编辑  收藏  举报