js-倒计时30秒

来源:互联网 发布:中国频道域名管理 编辑:程序博客网 时间:2024/05/03 06:14
<html>  
<head>  
<title>倒计时</title>  
<!--以下为css样式-->  
<style type= "text/css">  
.daojishi h2  
{   
font-family:Helvetica, Microsoft YaHei, Arial, sans-serif;   
font-size:14px;  
margin-bottom:5px;   
color:#151515;  
}  
.daojishi #timer  
{  
font-family:Helvetica, Microsoft YaHei, Arial, sans-serif;   
font-size:14px;  
color:#151515;  
font-weight:bold;  
}  
</style>  

</script>  
</head>  
<body onload = "timer()">  
<input type="redio" id="asd" name="asd" onclick="asd()">123
<div class = "daojishi">  
<h2>剩余时间为:</h2>  
<div id = "timer">  
</div>  
</div>  
</body> 
<script type="text/javascript">
var nowts=30000;
var aa=null;
function timer() {

showTime(nowts);

aa=setInterval("nowTimeOver()", 1000);

}
function nowTimeOver() {
console.info(12)
nowts = nowts - 1000;
showTime(nowts);
}
function showTime(ts) { 
if(nowts<1000){
window.clearInterval(aa); 


}
document.getElementById("timer").innerHTML = checkTime(parseInt(ts / 1000 % 60, 10)) + "秒";
}
function checkTime(i) {
if (i < 10) {
i = "0" + i;
}
return i;
}  
</script>
</html>  
0 0