我有一个拍卖网站的倒计时。在拍卖结束时,我想显示“一次性”。像真正的拍卖一样“去两次”和“最终通话”。此代码在second = 3处显示“going one”,在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");
}
}
我想更改此代码,以便在第二个= 0之前显示“一次性”,“两次”和“最终通话”,每个应显示1次。
我不知道该怎么做。
非常感谢您的帮助和建议。
答案 0 :(得分:0)
我已经快速模拟了一个倒计时钟,大致使用了你所拥有的内容: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);
这对您的问题有帮助吗?
答案 1 :(得分:0)
谢谢,对于你的答案,我想要更像这样的东西:
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等时添加1s。我不确定是否可能...谢谢
我使用query.countdown.js(http://keith-wood.name/countdown.html)