js倒计时
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<button id="btn" onclick="btns()" type="button" value="十秒后才能点击" >十秒后才能点击</button>
</body>
<script>
var n=10;//倒计时间
var btn=document.getElementById("btn");
function btns(){
btn.innerHTML="十秒后才能点击("+n+")";
if(n>0){
btn.setAttribute('disabled','true');
n--;
btn.innerHTML="十秒后才能点击("+n+")";
var time=setTimeout(btns,1000) ;
}else{
setTimeout(time);
btn.removeAttribute('disabled');
btn.innerHTML="十秒后才能点击";
n=10;
}
}
</script>
</html>