如何制作倒数计时器,显示减少到几天? [英] How can I make a countdown timer that shows decrease till days ?
问题描述
这是代码,用java:
如果有人帮忙的话会感激不尽:)
< div>
注册结束于< span id =timer>倒计时现在开始!< / span>分钟!
< / div>
< script>
window.onload = function() {
var day = 3
var hou = 24
var min = 1;
var sec = 3 ;
setInterval(function(){
document.getElementById(timer)。innerHTML = day +:+ hou + :+ min +:+ sec;
sec--;
if(sec == 00)
{
min--;
sec = 60;
if(min == 00)
{
hou--;
min = 60;
if(hou = 00)
{
day--;
hou = 24;
}
},1000);
}
< / script>
< blockquote>学习在纯JavaScript中创建简单倒数计时器 [ ^ ]
检查下面的程序,它可能对你有帮助。
< span id = 倒计时 class = timer > < / span > < script > var seconds = 60; function secondPassed(){var minutes = Math.round((seconds - 30)/ 60); var remainingSeconds =秒%60; if(remainingSeconds < 10) < span class =code-attribute> { remainingSeconds = < span class =code-keyword> 0 + remainingSeconds; < span class =code-attribute>} document.getElementById('countdown ').innerHTML = 分钟 + : + remainingSeconds; < span class =code-attribute> 如果 (秒 < span class =code-attribute> = = 0) { clearInterval(countdownTimer); document.getElementById('countdown')。innerHTML = Buzz Buzz ; } else { 秒 - ; } } var countdownTimer = setInterval(' secondPassed()', 1000); < /脚本 >
This is the code, with java :
Will be thankful if anyone helps:)
<div>
Registration closes in <span id="timer">Countdown starts now!</span> minutes!
</div>
<script>
window.onload = function(){
var day= 3
var hou= 24
var min = 1;
var sec = 3;
setInterval(function(){
document.getElementById("timer").innerHTML = day +" : " + hou +" : " + min +" : " + sec ;
sec--;
if(sec == 00)
{
min--;
sec = 60;
if (min == 00)
{
hou--;
min=60;
if (hou = 00)
{
day--;
hou=24;
}
},1000);
}
</script>
Learn to Create Simple Countdown Timer in Pure JavaScript[^]
Check below programm, it may be help you.
<span id="countdown" class="timer"></span> <script> var seconds = 60; function secondPassed() { var minutes = Math.round((seconds - 30)/60); var remainingSeconds = seconds % 60; if (remainingSeconds < 10) { remainingSeconds = "0" + remainingSeconds; } document.getElementById('countdown').innerHTML = minutes + ":" + remainingSeconds; if (seconds == 0) { clearInterval(countdownTimer); document.getElementById('countdown').innerHTML = "Buzz Buzz"; } else { seconds--; } } var countdownTimer = setInterval('secondPassed()', 1000); </script>
这篇关于如何制作倒数计时器,显示减少到几天?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!