jQuery60定时器

 

 

1、HTML

<div id='Code'></div>

  

 

 

2、JS

var wait=60;
$('#Code').text(wait+'s');
timer = setInterval(function(){ if(wait==0){ $('#Code').text('点击获取');
clearInterval(timer);//清除定时器 }else{ wait--; $('#Code').text(wait+'s');
} },1000);

  

var wait=60;
$('#AutoCode').text(wait+'s');
timer = setInterval(function(){
if(wait==0){
$('#AutoCode').text('获取验证码');
clearInterval(timer)
}else{
wait--;
$('#AutoCode').text(wait+'s');
}
},1000);
posted @ 2020-03-09 09:03  Ai~低调  阅读(161)  评论(0编辑  收藏  举报