倒计时

$(function(){
    timeCount(60,"time_id","........");
})
//倒计时
var timer=null;
function timeCount(time,ele,url){
    if(time>0){
        $("#"+ele).html(time+"s");
        clearTimeout(timer);
        timer=setTimeout(function(){
            time--;
            timeCount(time,ele,url);
        },980);
    }else{
        $("#"+ele).html(time+"s");
        setTimeout(function(){
            // 倒计时结束跳转url
            window.location.href=url;
        },1000);
    }
}

你可能感兴趣的:(倒计时)