我在这里添加了代码 当它在11点之后到达星期五时它应该倒数到11.00的钱 有什么建议/帮助到这儿? 另外:CountDown-timer还应该能够检查它在丹麦是否有假期(不确定这个功能,可能是一个控制该部分的数据库,因为节假日会有变量嗯?) http://jsfiddle.net/srwpyac0/24/
HTML:
<div id="countdown"></div>
的JavaScript
function ShowTime() {
var now = new Date();
if (now.getHours() > 11) {
var hrs = 11 - now.getHours() + 24;
} else {
var hrs = 11 - now.getHours();
}
var mins = 60 - now.getMinutes();
var secs = 60 - now.getSeconds();
timeLeft = "You now have " + hrs + ' Hour(s) ' + mins + ' minuts ' + secs + ' seconds' + " To complete the order, and make sure the delivery will reach to you in 1-3 days";
$("#countdown").html(timeLeft);
}
var countdown;
function StopTime() {
clearInterval(countdown);
}
setInterval(ShowTime, 1000);
答案 0 :(得分:0)
我不确定这是你想要的。请检查一次代码。
<强>使用Javascript:强>
function ShowTime() {
var now = new Date();
if (now.getHours() > 11){
var hrs =11-now.getHours()+24;
if(now.getDay() == 5){
var hrs = hrs + 48;
}
}else{
var hrs = 11-now.getHours();
}
var mins = 60-now.getMinutes();
var secs = 60-now.getSeconds();
timeLeft = "You now have "+hrs+' Hour(s) '+mins+' minuts '+secs+' seconds' +" To complete the order, and make sure the delivery will reach to you in 1-3 days";
$("#countdown").html(timeLeft);
}
var countdown;
function StopTime() {
clearInterval(countdown);
}
setInterval(ShowTime ,1000);
小提琴:Fiddle