如果秒=1,停止倒计时3秒,转到秒=0

If second = 1, stop countdown for 3 seconds, the go to second = 0

本文关键字:3秒 如果 倒计时      更新时间:2023-09-26

我有一个拍卖网站的倒计时。在拍卖结束时,我想展示"进行一次"。"去两次"answers"最后一次"就像真正的拍卖。此代码在second=3显示"进行一次",在second=2显示"进行两次",并在second=1显示"final call"。

if(hours == "00" && minutes == "00")
            {
                if(seconds < 50) { 
                        var color = thisDiv.css("background-color");
                        thisDiv.animate({color:"red"}, 'fast');
                        thisDiv.animate({color: "black"},'fast') ; 
                        }   
                        if(seconds == 3)
                        {
                            $(this).html("Going once!");    
                        }
                        if(seconds == 2)
                        {
                            $(this).html("Going twice!");   
                        }
                        if(seconds == 1)
                        {
                            $(this).html("Final call!");    
                        }
                        if(seconds == 0)
                        {
                            //$('.auction-current-time').countdown('destroy');
                            //$('.auction-current-time2').html("Auction Ended");
                            $(this).html("GONE!");
                            $(".mm_bid_mm").hide();
                             //alert("asd");    
                        }
            }

我想把这个代码改为只在second=0之前显示"进行一次"、"进行两次"answers"最终调用",每个都应该显示1s。

我不知道该怎么做。

非常感谢你的帮助和建议。

我已经制作了一个倒计时时钟的快速模型,大致使用了这里的内容:http://jsfiddle.net/uqxn2jhr/

var countDownClock = function (hours, minutes, seconds) {
    var clock = $('[data-countdown="clock"]');
    var time = $('[data-countdown="time"]');
    var quick = $('[data-countdown="quick"]');
    time.html(
    ((hours < 10) ? '0' : '') + hours + ':' + ((minutes < 10) ? '0' : '') + minutes + ':' + ((seconds < 10) ? '0' : '') + seconds);
    if (hours === 0 && minutes === 0) {
        if (seconds == 3) {
            quick.html("Going once!");
        }
        if (seconds == 2) {
            quick.html("Going twice!");
        }
        if (seconds == 1) {
            quick.html("Final call!");
        }
        if (seconds == 0) {
            //$('.auction-current-time').countdown('destroy');
            //$('.auction-current-time2').html("Auction Ended");
            quick.html("GONE!");
            //$(".mm_bid_mm").hide();
            //alert("asd");    
        }
    }
}
var beginCountDown = function (hours, minutes, seconds) {
    var countDown = setInterval(function () {
        seconds = seconds - 1;
        console.log(seconds);
        if (seconds < 0 && (minutes > 0 || hours > 0)) {
            //reset seconds and reduce hours/minutes
        }
        if (seconds >= 0) {
            countDownClock(hours, minutes, seconds);
        } else {
            clearInterval(countDown);
            countDown = null;
        }
    }, 1000);
};
beginCountDown(0, 0, 10);

这对你的问题有帮助吗?

谢谢你的回答,我想要更像这样的东西:

if(seconds == 4)
                    {
                        //$(this).html("Going once!");  
                    }
                    if(seconds == 3)
                    {
                        //$(this).html("Going twice!"); 
                    }
                    if(seconds == 2)
                    {
                        //$(this).html("Final call!");  
                    }
                    if(seconds == 1)
                    {
                        $('#box1').delay(1800).show('slow').promise()
                    .then(function(){ return $('#box2').delay(1800).show('slow').promise(); }).then(function(){ return $('#box2').delay(1800).hide('slow').promise(); }).then(function(){
return $('#box3').delay(1800).show('slow').promise(); }).then(function(){
return $('#box3').delay(1800).hide('slow').promise(); });
                    }
                    if(seconds == 0)
                    {
                    $(this).html("Bidding ended!");
                    }

我想在显示#box1时添加1,然后在显示#box2时添加1。我不确定是否可能…谢谢

我使用query.countdown.js(http://keith-wood.name/countdown.html)