<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title></title>
    <!--1.引入jq-->
    <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>

<body>

    <div >
        <span >15</span>小时
        <span >0</span>分
        <span >0</span>秒
    </div>


</body>

<!--3.倒计时js-->

<script type="text/javascript">
    var minute = "1";
    var second = 59;
    var hours = Math.floor(Math.random() * 10);
    $("#timeid2").text(hours);
    setInterval(function () {
        second--;
        if (second == 00 && minute == 00) {
            minute = 1;
            second = 59;
            var hours = Math.floor(Math.random() * 10);
            $("#timeid2").text(hours);
        };
        //当分钟和秒钟都为00时,重新给值
        if (second == 00) {
            second = 59;
            minute--;
            if (minute < 10) minute = "0" + minute;
        };
        //当秒钟为00时,秒数重新给值
        if (second < 10) second = "0" + second;
        $("#timeid3").text(minute);
        $("#timeid4").text(second);
    }, 1000);
</script>

</html>

这个功能是这样的,倒计时为0之后,随机获取小时数,然后又重新开始倒计时。  无限循环。

相关文章:

  • 2022-12-23
  • 2021-08-21
  • 2019-11-02
  • 2021-05-29
  • 2022-02-01
  • 2021-12-01
  • 2021-07-29
猜你喜欢
  • 2022-12-23
  • 2021-11-04
  • 2021-10-10
  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案