【发布时间】:2026-02-14 02:55:01
【问题描述】:
我有一个倒计时,每次天、小时和/或分钟改变时,改变的数字会闪烁红色 0.5 秒。
我不知道该怎么做...
这是计时器:
<script>
var countDownDate = new Date("Jan 10, 2019 00:00:00").getTime();
var x = setInterval(function() {
//datum und zeit getten
var now = new Date().getTime();
// Find the distance between now and the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Display the result in the element with id="demo"
document.getElementById("demo").innerHTML = "Noch " + days + " Tage, " + hours + " Stunden, "
+ minutes + " Minuten und " + seconds + " Sekunden bis zur Fertigstellung des Spiels!!! ";
if(days==0){
document.getElementById("demo").innerHTML = "Nur noch " + hours + " Stunden, "
+ minutes + " Minuten und " + seconds + " Sekunden bis zur Fertigstellung des Spiels!!! ";
}
if(days==0 && hours==0){
document.getElementById("demo").innerHTML = "Nur noch " + minutes + " Minuten und " + seconds + " Sekunden bis zur Fertigstellung des Spiels!!! ";
}
if(days==0 && hours==0 && minutes==0){
document.getElementById("demo").innerHTML= "Nur noch" + seconds + " Sekunden bis zur Fertigstellung des Spiels!!! ";
}
// If the count down is finished, write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("demo").innerHTML = "VERÖFFENTLICHT!";
}
if(days % 3==0){
document.getElementById("sup").style.display ="block";
}else {
document.getElementById("sup").style.display ="none";
}, 1000);
</script>
【问题讨论】:
-
欢迎来到 Stack Overflow。请始终包含所有相关代码(HTML、CSS 和 JavaScript),以便我们可以复制您的问题并为您提供有效的答案。但是,也请注意,我们不是代码编写服务或教程网站。我们希望您自己进行研究并尝试解决问题。然后,如果您遇到特定问题,您可以在此处提出相关问题。就目前而言,您实际上只是在寻求完整的解决方案,而没有先进行任何尝试。
标签: javascript timer colors countdown