<body>
<input type="text">
<button>发送</button>
<script>
var btn = document.querySelector('button');
var time = 10;
btn.addEventListener('click', function(){
btn.disabled = true;
//开启定时器
var timer = setInterval(function(){
if(time == 0){
clearInterval(timer);
btn.disabled = false;
btn.innerHTML = '发送';
//这个3 需要重新开始
time = 3;
}else{
btn.innerHTML = '还剩下' + time + '秒';
time--;
}
}, 1000)
})
</script>
</body>
定时器发送短信
最新推荐文章于 2022-04-21 15:48:10 发布