×

JQ 获取验证码倒计时方法

admin admin 发表于2016-07-20 21:12:31 浏览1756 评论0

抢沙发发表评论

html:
	<a href="javascript:;" class="weui_btn weui_btn_mini weui_btn_default"  id="show-notification">发送验证码</a>

script:
 // 设定倒数秒数
	var timenum = 60;
	// 显示倒数秒数
	function showTime() {
		timenum = timenum - 1;
		if (timenum > 0) {
			$("#show-notification").html(timenum + "s");
			$("#show-notification").attr("onclick", "");
			$("#show-notification").css({
				"cursor" : "default",
				"text-decoration" : "none",
				"color" : "blue"
			});
			// 每秒执行一次,showTime()
			setv = setTimeout("showTime()", 1000);
		} else if (timenum == 0) {
			$("#show-notification").html("获取验证码");
			$("#show-notification").attr("onclick", "sendCode()");
			$("#show-notification").css({
				"cursor" : "pointer",
				"text-decoration" : "none",
				"color" : "#9e9e9e"
			});
			timenum = 60;
		}
	}

blob.png

分享到:

群贤毕至

访客