码迷,mamicode.com
首页 > 其他好文 > 详细

倒计时

时间:2014-06-18 19:49:17      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:des   style   class   blog   code   java   

  今天学到了一个倒计时效果,本人脑子有点慢,琢磨了半天时间。做完之后给乱码看了下,学到了 一个知识点 x|0 取x整数 ,再此感谢乱码。

  

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>leftTime</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
<script type="text/javascript">
    var interval = 1000;
    function countDown(year,month,day,divname){
        var nowTime = new Date();
        var endTime = new Date(year,month-1,day);
        var leftTime =endTime.getTime()-nowTime.getTime();
        var leftSecondes = parseInt(leftTime/1000);
        var day1 = leftSecondes/(60*60*24) | 0;
        var hours = (leftSecondes - day1*60*60*24 ) / 3600 | 0 ;
        var minute = (leftSecondes - day1*60*60*24 - hours*3600)/60 | 0;
        var secondes = (leftSecondes - day1*60*60*24 - hours*3600 -minute*60) | 0;
        var oDemo = document.getElementById(divname);
        oDemo.innerHTML = "距离婚纱照:"+year+"年"+month+"月"+day+"日还有 "+day1+"天"+hours+"时"+minute+"分钟"+secondes+"秒";
    }
    window.setInterval(function(){
         countDown(2014,7,25,‘demo‘)
    },interval)
</script>
</head>
<body>
    <div id="demo"></div>
</body>
</html>

 

倒计时,布布扣,bubuko.com

倒计时

标签:des   style   class   blog   code   java   

原文地址:http://www.cnblogs.com/1989zhiyuan/p/3790619.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!