*本人小白
*点击按钮获取验证码倒计时
*直接上代码
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="./js/jquery.min.js" type="text/javascript"></script>
<script>
$(function(){
})
function getAuthentication(){
var getAuthentication=$("#btn");//获取输入框属性
getAuthentication.attr('disabled',true).css({//点击后禁止点击
'opacity':'0.5',
'cursor': 'no-drop',
});
var time =6;//设置倒计时事件
var setTime = setInterval(function(){
getAuthentication.val(+--time+"秒后重新获取")
},1000);
setTimeout(function(){//重新获取验证码
getAuthentication.attr('disabled',false).val('重新获取验证码').css({
'opacity':'1',
'cursor':'pointer',
});
clearInterval(setTime)//清除setTime
},6000)
}
</script>
</head>
<body>
<input type="button" id="btn" value="获取验证码" style="cursor: pointer" οnclick="getAuthentication()"/>
</body>
</html>