Blogger Information
Blog 44
fans 0
comment 0
visits 35512
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
JQuery2019年农历春节倒计时作业-2019年1月21日
的博客
Original
1088 people have browsed it

实例

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
    <title>Document</title>
    <style>
        *{padding:0%;margin: 0%;font-size: 1.2rem;color: white;} 
        div{width: 600px;height: 50px;background-color:lightcoral;position: absolute;left: 0%;top: 0%;bottom: 0%;right: 0;margin: auto;border-radius: 30px;}
        #time{margin: 0 auto;display: block;line-height: 50px;text-align: center;}
        div{box-shadow: 1px 2px 3px #888888;}
    </style>
    <script>
        $(document).ready(function () {
            //设置定时器,每1秒执行一次代码内容
            setInterval(function () {
                var myDate = new Date();//创建一个Date对象,存储当前时间
                var toDate = new Date();//创建一个Date对象,存储目标时间
                toDate.setFullYear(2019, 1, 5);//设置目标时间的年月日
                toDate.setHours(0, 0, 0, 0);//设置目标时间的时分秒
                var time = toDate - myDate;//目标时间-当前时间得出时间距离毫秒数
                var days = parseInt(time / (1000 * 60 * 60 * 24));//将时间距离毫秒数转为天数
                var hours = parseInt((time % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));//将时间距离毫秒数转为小时数
                var minutes = parseInt((time % (1000 * 60 * 60)) / (1000 * 60));//将时间距离毫秒数转为分钟数
                var seconds = parseInt((time % (1000 * 60)) / 1000);//将时间距离毫秒数转为秒数数
                $("#time").html("2019年农历春节倒计时" + days + " 天 " + hours + " 小时 " + minutes + " 分钟 " + seconds +
                    " 秒 ");
            }, 1000);

        });
    </script>
</head>

<body>
    <div>
        <span id="time"></span>
    </div>
    
</body>

</html>

运行实例 »

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


Correction status:qualified

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