06JavaScript美女时钟(秒改成分)

 1 <html xmlns="http://www.w3.org/1999/xhtml">
 2 <head>
 3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
 4     <title></title>
 5     <script type="text/javascript">
 6         onload = function () {
 7             //加载的时候要加载一次
 8             loadImage();
 9             setInterval(function () {
10                 //1、目的是拼接img标签下的字符串,所以要获取当前时间的小时和秒(分钟)
11                 //2、获取当前时间的小时和秒
12                 loadImage();
13             }, 1000);
14 
15             function loadImage() {
16                 var time = new Date();
17                 var h = time.getHours();
18                 if (h < 10) {
19                     h = '0' + h;
20                 }
21                 var sec = time.getSeconds();
22                 if (sec < 10) {
23                     sec = '0' + sec;
24                 }
25                 document.getElementById('imBtf').src = 'image/' + h + '_' + sec + '.jpg';
26             };
27 
28         };
29     </script>
30 </head>
31 <body>
32     <!--<img src="image/00_00.jpg" style="float:right;" />-->
33     <div style="height:300px;width:400px;background-color:green;margin:200px auto;">
34         <img src="" style="height:300px;" id="imBtf"/>
35     </div>
36 
37 </body>
38 </html>

 

posted on 2016-01-07 13:41  努力的活着_在人间  阅读(188)  评论(0)    收藏  举报

导航