加入css
<link href="../Admin/css/login.css" type="text/css" rel="stylesheet">
按钮
<input id="p" type="button" value="获取验证码" onclick="settime(this)" style="text-align:center;padding:10px 10px 30px 10px;90px;height:30px;font-size:13px;"/>
jQuery方法
<script type="text/javascript">
var countdown=120;
function settime(val) {
if (countdown == 0) {
val.removeAttribute("disabled");
val.value="获取验证码";
countdown = 120;
} else {
val.setAttribute("disabled", true);
val.value="重新发送(" + countdown + ")";
countdown--;
}
setTimeout(function() {
settime(val)
},1000)
}
</script>