<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>获取当前时间</title> <script type="text/javascript"> function getDate() { var currentTime=new Date().getHours()+":"+new Date().getMinutes()+":"+new Date().getSeconds(); var span=document.getElementById("timeSpan"); span.innerHTML=currentTime; window.setTimeout(getDate,1000); } </script> </head> body> <input type="button" id="" value="获取当前时间" onclick="getDate()"/> <span id="timeSpan"></span> </body> </html>
以上是显示时间的方法的详细内容。更多信息请关注PHP中文网其他相关文章!