$(function(){$("#fs").click(function(){$("#chkmsg").html("");var mob = $("#mob").val();var preg = /^((\+86)|(86))?((\(\d{3}\))|(\d{3}\-))?13[0-9]\d{8}|15[0-9]|18[0-9]\d{8}$/; //匹配手機號if(mob=='' || !preg.test(mob)){$("#chkmsg").html("<font color=red>請填寫正確的手機號!</font>");}else{$("#fs").attr("disabled","disabled").val('已發送手機驗證碼').css("cursor","default");$.post("duanxin.php",{mob:mob},function(file_contents){if(file_contents!=200){alert(file_contents)$("#chkmsg").html("發送失敗!");$("#fs").removeAttr("disabled").val('點擊重新發送驗證碼').css("cursor","pointer");}else{$("#chkmsg").html("短信驗證碼已成功發送!");}});}});})代碼如上,我該如何做到當判斷短信驗證碼已成功發送時將按鈕改為倒計時60秒后可點?
2 回答

www說
TA貢獻1775條經驗 獲得超8個贊
修改$.post 應該可以
$.post("duanxin.php",{mob:mob},function(file_contents){
if(file_contents!=200){
alert(file_contents)
$("#chkmsg").html("發送失敗!");
$("#fs").removeAttr("disabled").val('點擊重新發送驗證碼').css("cursor","pointer");
}else{
$("#chkmsg").html("短信驗證碼已成功發送!");
setTimeout(function(){
$("#fs").removeAttr("disabled").val('點擊重新發送驗證碼').css("cursor","pointer");
}, 60000);
}
});

喵喵時光機
TA貢獻1846條經驗 獲得超7個贊
else{
$("#chkmsg").html("短信驗證碼已成功發送!");
setTimeout('$("#fs").removeAttr("disabled").val('點擊重新發送驗證碼').css("cursor","pointer");
',60000)
}
用setTimeout就行了
添加回答
舉報
0/150
提交
取消