倒计时

作者: 洱月 | 来源:发表于2018-06-14 10:10 被阅读0次

    html

    <div class="next_time">
        <span>距离下一场竞猜</span>
        <div class="next_time_box">
            <div class="each_time">25</div><span>:</span>
            <div class="each_time">35</div><span>:</span>
            <div class="each_time">25</div>
        </div>
    </div>          
    

    倒计时 23:59:59

    //countDown($(".time_box.one"),"2018-06-12 00:00:00");
    function countDown(div, date) {
        var times = formIos(date).getTime() / 1000 - new Date().getTime() / 1000;
        var timer = null;
        timer = setInterval(function () {
            var hour = 0,
                minute = 0,
                second = 0;//时间默认值
            if (times > 0) {
                hour = Math.floor(times / (60 * 60));
                minute = Math.floor(times / 60) - (hour * 60);
                second = Math.floor(times) - (hour * 60 * 60) - (minute * 60);
            }
            if (hour <= 9) hour = '0' + hour;
            if (minute <= 9) minute = '0' + minute;
            if (second <= 9) second = '0' + second;
            div.find("div").eq(0).text(hour);
            div.find("div").eq(1).text(minute);
            div.find("div").eq(2).text(second);
            times--;
        }, 1000);
        if (times <= 0) {
            clearInterval(timer);
        }
    }
    

    相关文章

      网友评论

          本文标题:倒计时

          本文链接:https://www.haomeiwen.com/subject/trveeftx.html