jQuery五一劳动节倒计时

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/jquery-3.6.0.js"></script>
    <script>
        $(function () {
                setInterval(function () {
                    var now = new Date();
                    var workerDay = new Date("2021-5-1 00:00:00");
                    var second = (workerDay.getTime() - now.getTime()) / 1000;

                    var day = parseInt(second / (60 * 60 * 24));

                    second -= day * 60 * 60 * 24;

                    var hour = parseInt(second / (60 * 60));

                    second -= hour * 60 * 60;

                    var minute = parseInt(second / 60);

                    second -= minute * 60;

                    var restTime = "距离五一劳动节还有" + day + "天"
                        + hour + "小时" + minute + "分" + parseInt(second) + "秒";

                    $("#restTime").text(restTime);

                }, 1000)
            })
    </script>
</head>
<body>
    <h2 id="restTime"></h2>
</body>
</html>

jQuery五一劳动节倒计时

 

上一篇:js进制直接互相转换


下一篇:jquery 数值只能增加减少