您的位置:首页 > 其它

计时器

2016-06-06 10:08 267 查看
 function countDown(){

        var timeBox = $('.countdown i');

        var endTime = new Date(timeBox.data('time')),

            starTime = new Date(),

            ts = endTime.getTime()-starTime.getTime(),

            d= 0,

            h= 0,

            m = 0,

            s= 0;

        if(ts>=0){

            d=Math.floor(ts/1000/60/60/24);

            h=Math.floor(ts/1000/60/60%24);

            m=Math.floor(ts/1000/60%60);

            s=Math.floor(ts/1000%60);

        }

        timeBox.html(h+"小时"+m+"分"+s+"秒");

        setTimeout(countDown,1000);

    }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: