span标签获取验证码!!!(倒计时)

6 篇文章 0 订阅
4 篇文章 0 订阅

代码在下面!!!个人总结欢迎批判不足

 

<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<meta name="keywords" content="">
	<title>验证码倒计时</title>
	<style type="text/css">
		.verification{
			position:relative;
			width:400px;
		}
		.verification span{
			position: absolute;
			right: 0;
			top: 0;
			line-height: 55px;
			width: 130px;
			text-align: center;
			cursor: pointer;
			z-index: 10;
			background: #ddd;
			border-radius:5px;
		}
		.verification span.disabled{
			cursor: no-drop;
			color: #999;
		}
		.verification input{
			padding-right: 150px;
			width:220px;
			height: 53px;
			border: 1px solid #ddd;
			border-radius: 5px;
			margin-bottom: 15px;
			padding: 0 20px;
			font-size: 16px;
		}
	</style>
</head>
<body>
	<div class="verification">
		<input type="text" name="" id="" value="" maxlength="6" placeholder="动态码"/>
		<span onclick="settime($(this))">获取验证码</span>
	</div>
	<script src="http://code.jquery.com/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		var countdown=60; 
		function settime(obj) { 
			if(countdown == 0){
				obj.attr("onclick","settime($(this))");
				obj.text('重新发送');
				obj.removeClass('disabled')
				countdown=60;
				return;
			}else{
				obj.removeAttr("onclick"); 
				obj.text('已发送'+countdown);
				obj.addClass('disabled')
				countdown--
			};
			setTimeout(function(){
				settime(obj)
			},1000)
		}
	</script>
</body>
</html>

获取验证码前的样式

获取验证码后的样式

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值