早睡早起,方能养生
Sleep early rise early, way to keep healthy

js手机验证码倒计时

super
2019-03-25 11:37
views 2858


var countdown = 60;
function settime(obj)
{
    if (countdown == 0)
    {
        $(obj).attr("disabled", false);
        $(obj).text("获取验证码");
        countdown = 60;
        return false;
    }
    else
    {
        $(obj).attr("disabled", true);
        $(obj).text("重新发送(" + countdown + ")");
        countdown--;
    }
    setTimeout(function()
    {
        settime(obj);
    }, 1000);
}

obj是按钮对象





分享
0 条讨论
top