码迷,mamicode.com
首页 > Web开发 > 详细

购物网站倒计时

时间:2014-11-20 18:31:12      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   ar   color   sp   on   div   

bubuko.com,布布扣

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>拍卖倒计时</title>
<script>
window.onload=function(){
    function tick()
    {
        var oCount=document.getElementById(count);
        var timer=null;
        oDateTarget=new Date();
        oDateTarget.setFullYear(2014,10,20);
        oDateTarget.setHours(13,06,0,0);
        oDateNow=new Date();
        leftTime=parseInt((oDateTarget.getTime()-oDateNow.getTime())/1000);
        var day=parseInt(leftTime/(60*60*24));
        leftTime%=(60*60*24);
        var h=parseInt(leftTime/(60*60));
        leftTime%=(60*60);
        var m=parseInt(leftTime/60);
        leftTime%=60;
        oCount.innerHTML=day++h+小时+m+分钟+leftTime;
        if(leftTime<=0)
        {
            oCount.innerHTML=结束了;
            clearInterval(tick);
        }
    }
    tick();
    setInterval(tick,500)
};
</script>
</head>

<body>
<div>距离开始:<span id="count"></span></div>
</body>
</html>

 

购物网站倒计时

标签:style   blog   http   io   ar   color   sp   on   div   

原文地址:http://www.cnblogs.com/heboliufengjie/p/4111096.html

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