全国统一服务热线:400-633-9193

JS 60秒后重新发送验证码的实例讲解

    网络     2017-08-26    1128

废话不多说,直接上代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//settime($("#getPhoneCode"),60);
 
function settime($obj, time) {
  if (time == 0) {
    $obj.attr("disabled", false);
    $obj.css("background", "#f38401").css("cursor", "pointer");
    $obj.text("获取手机验证码");
    return;
  } else {
    $obj.attr("disabled", true);
    $obj.css("background", "#ccc").css("cursor", "not-allowed");
    $obj.text("重新发送(" + time + ")");
    time--;
  }
  setTimeout(function () { settime($obj, time) }, 1000)
}


  分享到:  
0.1921s