jQuery动态时钟

效果图:

代码:

 1 <!DOCTYPE html>
 2 <html>
 3     <head>
 4         <meta charset="utf-8" />
 5         <title></title>
 6         <script src="js/jQuery.js"></script>
 7     </head>
 8     <body>
 9         <p id="show"></p>
10         <script>
11             function setTime() {
12                     var date = new Date();
13                     var HH = date.getHours(),
14                         MM = date.getMinutes(),
15                         SS = date.getSeconds(),
16                         date = date.getDate();
17                         if(SS<10){
18                             SS = "0"+SS
19                         }
20                     $("#show").text(HH+":"+MM+":"+SS);
21                 }
22                 //设置时间间隔
23                 setInterval(setTime, 1000);
24         </script>
25     </body>
26 </html>

猜你喜欢

转载自www.cnblogs.com/ChenChaim/p/11747200.html