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

时间倒计时封装

时间:2018-09-27 13:04:27      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:就是   html   day   func   new   htm   dem   val   script   

html

<div class="demo_time"></div>

js

<script>
   //倒计时
   function djs(y,m,d,h,min,dom){
        var end=new Date(y,m,d,h,min);
        var star=new Date();
        var time=Math.ceil((end-star)/1000);
        var day=Math.floor(time/60/60/24);
        var hour=Math.floor((time-day*24*60*60)/60/60);
        var m=Math.floor((time-(day*24*60*60+hour*60*60))/60);
        var s=Math.floor(time%60);
       $(dom).html(day+"天"+hour+"小时"+m+"分"+s+"秒");
    }


    var timer1=setInterval(function(){
            djs(2018,8,30,0,0,".demo_time")
    },1000)
   // 实际月份要多一个月 比如 djs(2018,8,30,0,0,".demo_time") 就是 实际2018年9月30日
</script>

 

这样就可以粘贴复制直接用了。。。

时间倒计时封装

标签:就是   html   day   func   new   htm   dem   val   script   

原文地址:https://www.cnblogs.com/yangshousheng/p/9712335.html

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