BlackFungus

 

 效果:

<div class="nowTime">
  <span></span>年 
  <span></span>月 
  <span></span>日
  <span></span>: 
  <span></span>: 
  <span></span>
</div>
  
<script>
 $(document).ready(function() {
            function time() {

          var date = new Date();
          var n = date.getFullYear();
          var y = date.getMonth() + 1;
          var t = date.getDate();
          var h = (date.getHours()<10)?"0"+date.getHours():date.getHours();
          var m = (date.getMinutes()<10)?"0"+date.getMinutes():date.getMinutes();
          var s = (date.getSeconds()<10)?"0"+date.getSeconds():date.getSeconds();

                $(\'.nowTime span\').eq(0).html(n);
                $(\'.nowTime span\').eq(1).html(y);
                $(\'.nowTime span\').eq(2).html(t);
                $(\'.nowTime span\').eq(3).html(h);
                $(\'.nowTime span\').eq(4).html(m);
                $(\'.nowTime span\').eq(5).html(s);
                for (var i = 0; i < $(\'div\').length; i++) {
                    if ($(\'div\').eq(i).text().length == 1) {
                        $(\'div\').eq(i).html(function(index, html) {
                            return 0 + html;
                        });
                    }
                }
            }
            time();
            setInterval(time, 1000);
        });
<script>

 

分类:

技术点:

相关文章:

  • 2021-06-04
  • 2022-12-23
  • 2021-10-11
  • 2021-12-22
  • 2021-11-07
  • 2021-06-18
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-20
  • 2021-12-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-14
相关资源
相似解决方案