js倒计时功能
原创
©著作权归作者所有:来自51CTO博客作者java硕哥的原创作品,请联系作者获取转载授权,否则将追究法律责任
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
function $(id){
return document.getElementById(id);
}
var time = 24*60*60;
function changeTime(){
time = time-1;
var hours = Math.floor(time/(60*60));
hours = (hours>9?hours:('0'+hours))
var minitus = Math.floor(time/60%60);
minitus = (minitus>9?minitus:('0'+minitus))
var seconds =Math.floor(time%60%60);
seconds = (seconds>9?seconds:('0'+seconds));
$('time').innerHTML = hours +':'+minitus +':'+seconds ;
}
setInterval('changeTime()',1000);
</script>
</head>
<body>
<div style='font-size:111px' id='time'></div>