引用js
<script language="javascript" src="jquery-1.10.2.js"></script>
js
<script language="javascript">
$(document).ready(function(){
var intSecond=60;
timer(intSecond);
});
function timer(intSecond){
window.setInterval(function(){
var day=0;
var hour=0;
var minute=0;
var second=0;
if(intSecond>0){
day=Math.floor(intSecond/(60*60*24));
hour=Math.floor(intSecond/(60*60)-day*24);
minute=Math.floor(intSecond/60-day*24*60-hour*60);
second=Math.floor(intSecond)-day*24*60*60-hour*60*60-minute*60;
}
if(hour<=9){
hour='0'+hour;
}
if(minute<=9){
minute='0'+minute;
}
if(second<=9){
second='0'+second;
}
$("#day_show").html(day+'天');
$("#hour_show").html(hour+'时');
$("#minute_show").html(minute+'分');
$("#second_show").html(second+'秒');
intSecond--;
},1000);
}
</script>
html
<h1>
jQuery倒计时
</h1>
<div>
<span id="day_show">
0天
</span>
<strong id="hour_show">
0时
</strong>
<strong id="minute_show">
0分
</strong>
<strong id="second_show">
0秒
</strong>
</div>
posted on
浙公网安备 33010602011771号