• Jquery 一个页面单个倒计时 实现


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>单个timeout</title>
         <script src="/Content/js/jquery-1.10.2.min.js" type="text/javascript"></script>
    </head>
    <body>
    <p id="countDown1"></p>
      
        <script type="text/javascript">
            function getCountDown(timestamp) {
                var timer = setInterval(function () {
                    var nowTime = new Date();
                    var endTime = timestamp;
    
                    var t = endTime - nowTime.getTime();
    
                    if (t <= 0) {
                        $("#countDown1").html('over');
                        clearInterval(timer);
                        return false;
                    }
                    
                    var d=Math.floor(t/1000/60/60/24);
                    var hour = Math.floor(t / 1000 / 60 / 60 % 24);
                    var min = Math.floor(t / 1000 / 60 % 60);
                    var sec = Math.floor(t / 1000 % 60);
    
                    if (hour < 10) {
                        hour = "0" + hour;
                    }
                    if (min < 10) {
                        min = "0" + min;
                    }
                    if (sec < 10) {
                        sec = "0" + sec;
                    }
                    var countDownTime = d + "" + hour + ":" + min + ":" + sec;
                    $("#countDown1").html(countDownTime);
    
                }, 1000);
            }
    
            var date = '2019-04-02 10:33:00.0';
            date = date.substring(0, 19);
            date = date.replace(/-/g, '/');
            var timestamp = new Date(date).getTime(); // 毫秒级
    
            getCountDown(timestamp);
        </script>
    
    </body>
    </html>
  • 相关阅读:
    Codeforces Round #353 (Div. 2)
    Codeforces Round #304 (Div. 2)
    Codeforces Round #250 (Div. 2)D
    Codeforces Round #368 (Div. 2)
    hdu4348区间更新的主席树+标记永久化
    poj3468线段树标记永久化
    Educational Codeforces Round 35 (Rated for Div. 2)
    一维数组取一部分
    序列化数组。
    禅道常识
  • 原文地址:https://www.cnblogs.com/Fooo/p/10456298.html
Copyright © 2020-2023  润新知