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

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

WBOY
Release: 2016-06-13 13:41:09
Original
838 people have browsed it

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

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

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>
Copy after login
探讨

HTML code



Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template