反复性定时器:
创建一个反复性定时器名字叫做timer1
var timer1 = window.
setInterval(“f1();”,t1);
清除(停止)一个反复性定时器timer1
window.clearInterval( timer1 );
一次性定时器:
创建一个一次性定时器名字叫做timer2
var timer2 = window.setTimeout(“f2();”,t2);
清除(停止)一个一次性定时器timer2
window.clearTimeout( timer2 );
//多久后跳转到指定url
setInterval(function(){
var now = parseInt($('.s_back').html());
now--;
if (now<=0) {
window.location.href="/index.php?m=content&c=enroll&a=meet&id={:$order['id']:}";
}
$('.s_back').html(now);
},1000);
//10秒倒计时
var i = 10;
$(".time").click(function(){
$(".time").val("10秒后重新发送");
var timer = setInterval(function(){
if(i<0){
clearInterval(timer);
$('.time').css('color','#000');
$('.time').val('获取验证码');
}else{
$('.time').val(i+'秒后重新发送');
$('.time').css('color','#999');
$('.time').attr("disabled",true);
}
i--;
},1000)
});