京东商城秒杀源码

!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>

    <style>

        * {

            padding: 0;

            margin: 0;

        }

        .box {

            position: relative;

            margin: 100px auto;

            width: 240px;

            height: 340px;

            padding-top: 51px;

            background-color: red;

            text-align: center;

            box-sizing: border-box;

        }

        .p1 {

            width: 240px;

            height: 70px;

            line-height: 70px;

            color: aliceblue;

            font-size: 40px;

        }

        .p2 {

            width: 240px;

            height: 40px;

            line-height: 40px;

            color: #ccc;

            font-size: 23px;

        }

        .p3 {

            width: 240px;

            height: 60px;

            line-height: 60px;

            font-size: 20px;

            color: #fff;

        }

        .p4 {

            width: 240px;

            height: 45px;

            line-height: 45px;

            font-size: 18px;

            color: #fff;

        }

        .times {

            width: 240px;

            height: 74px;

            text-align: center;

        }

        span {

            display: inline-block;

            margin-top: 12px;

            width: 50px;

            height: 50px;

            background-color: #000;

            margin-right: 5px;

            font-size: 30px;

            color: #fff;

            line-height: 50px;

        }

    </style>

</head>

<body>

    <div class="box">

        <div class="'txt">

            <div class="p1">京东秒杀</div>

            <div class="p2">给个关注</div>

            <div class="p3">CSDN:秋叶00</div>

            <div class="p4">本场距离结束还剩</div>

        </div>

        <div class="times">

            <span class="hours">2</span>

            <span class="min">3</span>

            <span class="second">5</span>

        </div>

    </div>

    <script>

        var hours = document.querySelector('.hours')

        var min = document.querySelector('.min')

        var second = document.querySelector('.second')

        var now = +new Date('2022-7-1 00:00:00'); //返回用户输入时间总毫秒数

        getDaojishi();

        //  开启定时器

        setInterval(getDaojishi, 700)

        function getDaojishi(time) {

            var date = +new Date(); //时间总毫秒数

            var times = (now - date) / 1000; //剩余时间总秒数

            var t = parseInt(times / 60 / 60 / 24); //天

            t = t < 10 ? '0' + t : t;

            var h = parseInt(times / 60 / 60 % 24); //小时

            h = h < 10 ? '0' + h : h;

            hours.innerHTML = h;

            var m = parseInt(times / 60 % 60); //分钟

            m = m < 10 ? '0' + m : m;

            min.innerHTML = m;

            var s = parseInt(times % 60); //秒

            s = s < 10 ? '0' + s : s;

            second.innerHTML = s;

            // return t + '天' + h + '小时' + m + '分钟' + s + '秒'

        }

    </script>

</body>

</html>

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

秋叶00

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值