zoukankan      html  css  js  c++  java
  • js jq手机验证码发送

    js:
    
    <input type="button" id="btn" value="免费获取验证码" />
    <script type="text/javascript">
    var wait=60;
    function time(o) {
            if (wait == 0) {
                o.removeAttribute("disabled");           
                o.value="免费获取验证码";
                wait = 60;
            } else { // www.jbxue.com
                o.setAttribute("disabled", true);
                o.value="重新发送(" + wait + ")";
                wait--;
                setTimeout(function() {
                    time(o)
                },
                1000)
            }
        }
    document.getElementById("btn").onclick=function(){time(this);}
    
    </script>
    
    
    jq:(js的那个在我的项目上不是很好用自己写了一个jq的)
    
                var step = 59;
                $('#btn').val('重新发送60');
                var _res = setInterval(function()
                {   
                    $("#btn").attr("disabled", true);//设置disabled属性
                    $('#btn').val('重新发送'+step);
                    step-=1;
                    if(step <= 0){
                    $("#btn").removeAttr("disabled"); //移除disabled属性
                    $('#btn').val('获取验证码');
                    clearInterval(_res);//清除setInterval
                    }
                },1000);
  • 相关阅读:
    套接字(socket)
    网络编程
    面向对象之反射
    面向对象的多态
    面向对象之封装
    面向对象之继承
    面向对象之编程思想
    python中的包
    python中的序列化模块
    正则表达式
  • 原文地址:https://www.cnblogs.com/zjunet/p/4559896.html
Copyright © 2011-2022 走看看