chenfahui'Blog

陈发辉的个人主页 chenfahui.cn

« 不知道你现在何方,为何不说话

倒计时js

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>倒計時</title>
</head>
 
<body>
剩余时间:<span id="expireTime"></span>
<script type="text/javascript">
   var expire = 2412169;
   var expireTime = function(expires){
       if(expires > 0){
           var second = expires;
       }else{
           var second = "0 分";
           return second;
       }
       var day = hour = min = "";
       if(second>86400){
           day = Math.floor(second/86400)+"天 ";
           second = second%86400;
       }
       if(second>3600){
           hour = Math.floor(second/3600)+"时 ";
           second = second%3600;
       }
       if(second>60){
           min = Math.floor(second/60)+"分 ";
           second = second%60;
       }
       second = second+"秒";
       return day+hour+min+second;
   }
    
   var timeEle = document.getElementById("expireTime");
    
   var timer = window.setInterval(function(){
       timeEle.innerHTML = expireTime(expire--);
       if(expire<0){
           clearInterval(timer);
       }
   },1000);
</script>
</body>
</html>
 
 

发表评论

网站分类

文章归档

Tags

Powered By Z-Blog 1.8 Walle Build 100427
Copyright 2009-2012 chenfahui.cn. Some Rights Reserved.www.chenfahui.cn网站PR查询