验证码60秒倒计时

验证码60秒倒计时(jQuery),

代码如下:

                //验证码倒计时
                var countdown = 60;
                var st;
                function settime(element) {
                    if (countdown != 0) {
                        st = setTimeout(function () {
                            settime(element);
                        }, 1000);
                    }
                    if (countdown == 0) {
                        element.removeAttr("disabled");
                        element.val("获取验证码");
                        element.removeAttr("style");
                        countdown = 60;
                        window.clearTimeout(st);
                    } else {
                        element.attr("disabled", true);
                        element.css({"background":"#CCC","color":"#fff"});
                        element.val("重新发送(" + countdown + ")");
                        countdown--;
                    }
                }
时间: 2024-08-08 01:12:43

验证码60秒倒计时的相关文章

js实现60秒倒计时效果(使用了jQuery)

今天碰到要实现一个类似那种短信验证码60秒倒计时的需求,好久不写js,有点手生.把代码记录下,方便后续查阅. 这里我用了jQuey,毕竟写起来简洁点.下面直接看效果和代码. 一.效果 二.代码 (1)html <input type="button" id="btn" value="免费获取验证码" onclick="daojishi(10,this)" /> 注意:要引入JQuery (2)js <scri

js jquery 按钮点击后 60秒之后才能点击 60秒倒计时

var wait = 60; function time(o) { if (wait == 0) { $(o).attr("disabled", false); $(o).val("获取验证码"); wait = 60; } else { $(o).attr("disabled", true); o.val(wait + "秒后重新发送"); wait--; setTimeout(function () {time(o);},

yii框架实现注册页面短信验证60秒倒计时

先说下简单的,直接用jquery来实现短信验证60秒倒计时,然后在说明在yii框架下怎么实现的. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">

淘宝60秒倒计时

<!DOCTYPE html> <html> <head> <title>60秒倒计时</title> <script type="text/javascript"> window.onload=function(){ var oBtn = document.getElementById('but'); var conut = 60; var timer = null; oBtn.onclick=function(

点击按钮出现60秒倒计时js代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-

jQuery实现发送短信验证码后60秒倒计时

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script> <script type="text/javascript"> var countdown=60; functi

获取验证码,60秒倒计时js

<input type="button" id="btn" value="免费获取验证码" /><script type="text/javascript">var wait=60;function time(o) {        if (wait == 0) {            o.removeAttribute("disabled");                  

60秒倒计时

<input type="button" id="btn" value="免费获取验证码" onclick="settime(this)" /> <script type="text/javascript"> var countdown=60; function settime(val) { if (countdown == 0) { val.removeAttribute(&quo

Jquery 插件防刷新 60秒倒计时

//先到官网(http://plugins.jQuery.com/cookie/)下载cookie插件,放到相应文件夹,代码如下: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>