点击倒计时重发
##代码
// An highlighted block
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script>
window.onload=function(){
var btn=document.getElementById("btn");
var count=5;
var timer=null;
btn.onclick=function(){
clearInterval(timer);
this.disabled=true;
var that=this;
timer=setInterval(function(){
count--;
if(count>=0){
that.innerHTML="还剩"+count+"秒";
}else{
that.innerHTML="重新发送短信";
that.disabled=false;
clearInterval(timer);
count=5;
}
},1000)
}
}
</script>
</head>
<body>
<input type="text"/>
<button id="btn">点击发送短信</button>
</body>
</html>