Blogger Information
Blog 20
fans 0
comment 0
visits 25268
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
jquery实现日期倒计时
左手Leon的博客
Original
813 people have browsed it

实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>日期倒计时</title>
    <style type="text/css">
        *{margin:0;padding: 0}
        div{
            font-size: 40px;
            width: 1200px;
            height: 200px;
            margin:100px auto;
            background:green;
            line-height: 180px;
            color: #fff;
            text-align: center;
        }
    </style>
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"> </script>
</head>
<body>
    <div id='box'>
        <p>2019年劳动节倒计时:<span></span></p>
    </div>


    <script>
        $(document).ready(function(){
            function countDown(){
                var d=Date.parse("May 01,2019");
                // console.log(d);
                var date=new Date();
                var dd=date.getTime();
                var rd=Math.floor((d-dd)/1000);
                var days=Math.floor(rd/86400);
                var hours=Math.floor(rd%86400/3600);
                var minutes=Math.floor(rd%3600/60);
                var seconds=Math.floor(rd%60);
                $('span').text(days+'天'+hours+'小时'+minutes+'分'+seconds+'秒')
                // console.log(hours);
            }
            setInterval(countDown,1);

        })
    </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