js短信验证码时间

短信验证码时间

比较简单直接上代码:

var wait = 60;
timeOut();
function timeOut() {
  if (wait == 0) {
    $('#code').text("重新获取验证码");
  } else {
    setTimeout(function () {
      wait--;
      $('#code').text(wait);
      timeOut();
    }, 1000)
  }
}

posted @ 2018-05-03 09:47  菜_鸟o  阅读(132)  评论(0编辑  收藏  举报