$(document).ready(function()
{
var days = 03; var hours = 18; var minutes = 00; var seconds = 00;
function calculate()
{
setTimeout(calculate, 1000); $('#showDate').html(days + ':' + hours + ':' + minutes + ':' + seconds);
seconds--;
if (seconds < 0) { seconds = 59; minutes--;
if (minutes < 0) { hours--; minutes = 59;
if (hours < 0) { days--; hours = 23;
if (days < 0) { days = 0; hours = 0; minutes = 0; seconds = 0;
}}}}
}
calculate();
});
&#13;
<script type='text/javascript' src='http://code.jquery.com/jquery-1.10.2.min.js'></script>
<div id='showDate'></div>
&#13;
希望你们一切顺利。
来点,我想重置每90小时后使用jquery创建的倒计时。
我还写了下面的代码。
90小时后它不会在3天18小时后重置。
请帮助我。
<script type='text/javascript' src='http://code.jquery.com/jquery-1.10.2.min.js'></script>
<script type='text/javascript'>
$(document).ready(function()
{
var days = 03; var hours = 18; var minutes = 00; var seconds = 00;
function calculate()
{
setTimeout(calculate, 1000); $('#showDate').html(days + ':' + hours + ':' + minutes + ':' + seconds);
seconds--;
if (seconds < 0) { seconds = 59; minutes--;
if (minutes < 0) { hours--; minutes = 59;
if (hours < 0) { days--; hours = 23;
if (days < 0) { days = 0; hours = 0; minutes = 0; seconds = 0;
}}}}
}
calculate();
});
</script>
<div id='showDate'></div>
答案 0 :(得分:0)
您可以尝试以下内容:
<script type='text/javascript' src='http://code.jquery.com/jquery-1.10.2.min.js'></script>
<script type='text/javascript'>
$(document).ready(function()
{
var days = 00; var hours = 00; var minutes = 1; var seconds = 00;
function calculate()
{
setTimeout(calculate, 1000); $('#showDate').html(days + ':' + hours + ':' + minutes + ':' + seconds);
if(days == 0 && hours ==00 && minutes == 0 && seconds == 00)
{
minutes = 1;
}
seconds--;
if (seconds < 0) { seconds = 59; minutes--;
if (minutes < 0) { hours--; minutes = 59;
if (hours < 0) { days--; hours = 23;
if (days < 0) { days = 0; hours = 0; minutes = 0; seconds = 0;
}}}}
}
calculate();
});
</script>
<div id='showDate'></div>
答案 1 :(得分:0)
<script type='text/javascript' src='http://code.jquery.com/jquery-1.10.2.min.js'></script>
<script type='text/javascript'>
$(document).ready(function()
{
var days = 03; var hours = 18; var minutes = 00; var seconds = 00;
function calculate()
{
setTimeout(calculate, 1000); $('#showDate').html(days + ':' + hours + ':' + minutes + ':' + seconds);
seconds--;
if (seconds < 0) { seconds = 59; minutes--;
if (minutes < 0) { hours--; minutes = 59;
if (hours < 0) { days--; hours = 23;
if (days < 0) { days = 0; hours = 0; minutes = 0; seconds = 0;
}}}}
if((seconds == 0) && (minutes == 0) && (hours == 0) && (days == 0))
{
days = 03;
hours = 18;
minutes = 00;
seconds = 20;
}
}
calculate();
});
</script>
<div id='showDate'></div>