當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
【javascript】不刷新页面,实时显示当前时间
生活随笔
收集整理的這篇文章主要介紹了
【javascript】不刷新页面,实时显示当前时间
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
這里起主要作用的是setTimeout這個函數。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="content-type" content="text/html;charset=gb2312" /><title>JS小測試</title></head><body><style type="text/css">#time{background-color:#eee;}</style><script type="text/javascript">function showtime(){var myDate = new Date();document.getElementById("time").innerHTML = myDate.getHours() + "時" + myDate.getMinutes() + "分" + myDate.getSeconds() + "秒" ;setTimeout("showtime()",1000); / } </script><div id="time"><script type="text/javascript">showtime();</script></div></body> </html>
?
轉載于:https://www.cnblogs.com/whongfei/archive/2012/10/03/5247029.html
總結
以上是生活随笔為你收集整理的【javascript】不刷新页面,实时显示当前时间的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 工业控制系统专业术语(不断完善中)
- 下一篇: JSP邮箱信息截取