1. 程式人生 > >JS 60秒後重發送驗證碼

JS 60秒後重發送驗證碼

cti text logs fun 驗證 out clas .text cnblogs

//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) }

JS 60秒後重發送驗證碼