gpt4 book ai didi

javascript - 每日特定时间倒计时

转载 作者:行者123 更新时间:2023-11-28 19:54:33 27 4
gpt4 key购买 nike

我正在尝试进行每日倒计时,例如每天直到晚上 7 点。一旦晚上 7 点过去,它应该在 23:59:59 重新开始,并再次倒计时到第二天晚上 7 点。

我写了一个脚本,但没有显示任何内容。为什么倒计时不显示?

演示:http://jsfiddle.net/8Ab78/

function ShowTime() {
var now = new Date();
var hrs = 18-now.getHours();
var mins = 60-now.getMinutes();
var secs = 60-now.getSeconds();
timeLeft = "" +hrs+' hours '+mins+' minutes '+secs+' seconds';
$("#countdown").html(timeLeft);
}

var countdown;
function StopTime() {
clearInterval(countdown);
setInterval(ShowTime ,1000);
}

最佳答案

替换

setInterval('ShowTime()',1000);

到此

setInterval(ShowTime ,1000);

Fiddle

关于javascript - 每日特定时间倒计时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22807091/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com