fuxiaoyon

倒计时

这是css:
  <style>
    .box{color:red;
      width:80%;
      margin: 50px auto;
      font-size: 45px}
  </style>
 
这是HTML代码:
  <div class="box"></div>
 
 
这是js代码:
        var div = document.querySelector(".box");
        var timer = setInterval(count, 1)

        function count(){
            var a = new Date().getTime();
            var b = new Date("2019/1/1 00:00:00").getTime();
            var arr = b - a;

            var one = parseInt(arr / 1000 / 60 / 60 / 24);
            var two = parseInt(arr / 1000 / 60 / 60 % 24);
            var three = parseInt(arr / 1000 / 60 % 60);
            var four = parseInt(arr / 1000 % 60);

            one = one < 10 ? "0" + one : one;
            two = two < 10 ? "0" + two : two;
            three = three < 10 ? "0" + three : three;
            four = four < 10 ? "0" + four : four;


            div.innerHTML = "今年还剩下" + one + "天" +  two + "时" + three + "分" + four + "秒";

        }

分类:

技术点:

相关文章:

  • 2021-12-05
  • 2021-12-05
  • 2021-12-05
  • 2021-12-05
  • 2021-12-05
  • 2021-12-02
  • 2021-12-15
  • 2021-12-05
猜你喜欢
  • 2021-12-13
  • 2021-12-05
  • 2021-12-15
  • 2021-12-15
  • 2021-09-26
  • 2021-12-12
相关资源
相似解决方案