完整代码如下
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> <script> $(function(){ setInterval(function() { var time =(new Date()).toLocaleString(); $('#now_time').text(time); },1000); }) </script> </head> <body> <span id="now_time"></span> </body> </html>
效果图:
时间会间隔一秒更新一次
来自ansion博客
2016年7月22日