Blogger Information
Blog 34
fans 1
comment 0
visits 57190
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
10行JQ搞定验证码发送
Y的博客
Original
921 people have browsed it
$(".code").on("click", function() {
    var s = parseInt($(".code b").html());
    var phone = $("#phone").val();
    if (s > 0) {
        layer.msg("请等待" + s + "秒重发")
        return false;
    }
    $.post("{:U('code')}", {
        phone: phone
    }, function(e) {
        if (e.status == 1) {
            $(".code").html("等待<b>60</b>秒");
            var ping = window.setInterval(function() {
                var s = parseInt($(".code b").html());
                if (s == 0) {
                    $(".code").html("重发验证码")
                    clearInterval(ping);
                    return false;
                } else {
                    $(".code b").html(s - 1);
                }
            }, 1000);
        } else {
            layer.msg(e.info);
        }
    });
    return false;
})

Html代码

 <em class="code">获取验证码</em>


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post