<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<button id="getPhoneCode"></button>
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script>
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","noe-allowed");
$obj.text("重新发送("+time+")");
time--;
}
setTimeout(function(){settime($obj,time)},1000);
}
settime($("#getPhoneCode"),60);
</script>
</body>
</html>
JS 60秒后重发送验证码
最新推荐文章于 2024-02-03 11:02:39 发布