Maison > Article > développement back-end > 怎么实现当前时间显示并不刷新实时更新?求大神帮帮忙
如何实现当前时间显示并不刷新实时更新?求大神帮帮忙!
如题,麻烦知道的告知下小弟,最好附上代码!谢谢!
------解决方案--------------------
<script type="text/javascript">function startTime(){var today=new Date()var h=today.getHours()var m=today.getMinutes()var s=today.getSeconds()// add a zero in front of numbers<10m=checkTime(m)s=checkTime(s)document.getElementById('txt').innerHTML=h+":"+m+":"+st=setTimeout('startTime()',500)}function checkTime(i){if (i<10) {i="0" + i} return i}</script><div id="txt"></div><br><font color="#e78608">------解决方案--------------------</font><br>