jq 两种倒计时

第一种:

        //暂停时间
        var delay = (function () {
            var timer = 0;
            return function (callback, time) {
                clearTimeout(timer);
                timer = setTimeout(callback, time);
            };
        })();

        //5秒后停止下注
        delay(function () {
            var i=0;
            var oTd = document.getElementById('td1');
            var children = oTd.children;
            for(i = 0; i < children.length; i++) {
                children[i].disabled=true;
                children[i].style.backgroundColor = "#EEEEEE";
            }
        }, 5000);

第二种:

        Surplustime(5);
        // 下注倒计时函数
        function Surplustime(seconds){
            if(seconds == 0){
                clearTimeout(timer);
                Pushtime(5);
                return;
            }
            // seconds--;
            $('.timetxt').text('开始倒计时:');
            $('.overtime').text((seconds) + '秒后 停止下注');
            var timer = setTimeout(function(){
                Surplustime(seconds);
            },1000);
            seconds--;
        }
原文地址:https://www.cnblogs.com/ycqi/p/9372043.html