<style>
.tableText{
display: inline-block;
width: 120px;
height: 50px;
text-align: center;
background-color: black;
font-size: 12px;
font-weight: bold;
cursor: pointer;
color: whitesmoke;
line-height: 50px;
text-decoration: none;
border-radius: 5px;
}
</style>
<input class="tableText" type="button" value="发送验证码">
$(document).ready(function () {
var minth = 10;//初始值
var mytime;//定时函数
//封装一个倒计时方法
function fn() {
minth = --minth;//自减一
if (minth>0){//还没有倒计时结束
$(".tableText").val('('+minth+'秒)后重发')
$(".tableText").attr("disabled","disabled")
}else {//倒计时结束
clearInterval(mytime);
$(".tableText").removeAttr("disabled")
minth = 10;//重新返回10
$(".tableText").val('发送验证码')
}
}
$(".tableText").click(function () {
clearInterval(mytime);
mytime = setInterval(fn,1000);
})
})