Blogger Information
Blog 13
fans 1
comment 0
visits 8540
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
20190401_jquery基础1_作业
蛋炒饭的博客
Original
602 people have browsed it

实例  jquery完成的倒计时

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>倒计时</title>
    <script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
    <style type="text/css" media="screen">
        *{
            margin: 0;
            padding: 0;
        }
        img{
            border:0;
        }
        ol, ul ,li{list-style: none;}
        #kk{
            width:1000px;
            height:100px;
            line-height: 100px;
            background: #039293;
            color:#fff;
            font-size: 40px;
            text-align:center;
            margin:100px auto;
        }
    </style>
</head>
<body>

    <div id="kk">
        <p>距离劳动节还有:<span></span></p>
    </div>
    <script>
        $(function(){
            function Ro(){
                //当前时间戳
                var d = new Date().getTime();
                //1970年的时间戳
                var dd = new Date("2019-05-01 0:0:0").getTime();
                //获取今天距离劳动节的总毫秒
                var times = dd-d;
                //获取天数
                var get_days = Math.floor(times/1000/3600/24);
                //获取小时
                var get_hours =  Math.floor((times/1000/3600)%24);
                //获取分钟
                var get_minutes = Math.floor((times/1000/60)%60);
                //获取秒
                var get_seconds = Math.floor((times/1000)%60);

                $('#kk span').text(get_days+'天'+get_hours+'时'+get_minutes+'分'+get_seconds+'秒');
            }

            setInterval(Ro,1000);

        })
    </script>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例


Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post