问答详情
源自:8-3 计时器setInterval()

可能是最简洁的回答了

<script type="text/javascript">  var attime;  function clock(){    var time=new Date();              attime= time.getHours().toString()+":"+time.getMinutes().toString()+":"+time.getSeconds().toString() ;    document.getElementById("clock").value = attime;  }  setInterval(clock,1000);</script>


提问者:慕盖茨8203141 2020-05-25 09:44

个回答

  • kenscut
    2021-06-13 13:41:44

    <script type="text/javascript">

      var attime;

      function clock(){

        var time=new Date();

        var myarr=time.split(" ");

        attime=myarr[4];

        document.getElementById("clock").value = attime;

      }

      setInterval(clock,1000);

    </script>


  • 慕莱坞0135150
    2020-05-27 11:21:50

     setInterval(clock,1000);