Home  >  Article  >  Backend Development  >  怎么实现当前时间显示并不刷新实时更新?求大神帮帮忙

怎么实现当前时间显示并不刷新实时更新?求大神帮帮忙

WBOY
WBOYOriginal
2016-06-13 13:41:09788browse

如何实现当前时间显示并不刷新实时更新?求大神帮帮忙!
如题,麻烦知道的告知下小弟,最好附上代码!谢谢!

------解决方案--------------------

HTML code



<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<10
m=checkTime(m)
s=checkTime(s)
document.getElementById('txt').innerHTML=h+":"+m+":"+s
t=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>
探讨

HTML code



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn