标签:
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>8.13第五题</title> 6 </head> 7 <body onLoad="item()"> 8 <img id="ho1" src="time_num_0.png"> 9 <img id="ho2" src="time_num_0.png"> 10 <img id="sign1" src="time_num_colon.png"> 11 <img id="mi1" src="time_num_0.png"> 12 <img id="mi2" src="time_num_0.png"> 13 <img id="sign1" src="time_num_colon.png"> 14 <img id="se1" src="time_num_0.png"> 15 <img id="se2" src="time_num_0.png"> 16 <div style="margin: 20px 0;"> 17 <button onclick="start()">start</button> 18 <button onclick="stop()">stop</button> 19 </div> 20 <script> 21 var hour,min,sec,h1,h2,m1,m2,s1,s3; 22 var ho1,ho2,mi1,mi2,se1,se2; 23 var tid; 24 function item(){ 25 var date=new Date(); 26 hour=date.getHours(); 27 min=date.getMinutes(); 28 sec=date.getSeconds(); 29 h1=parseInt(hour/10); 30 h2=hour%10; 31 m1=parseInt(min/10); 32 m2=min%10; 33 s1=parseInt(sec/10); 34 s2=sec%10; 35 ho1=getId("ho1"); 36 ho2=getId("ho2"); 37 mi1=getId("mi1"); 38 mi2=getId("mi2"); 39 se1=getId("se1"); 40 se2=getId("se2"); 41 ho1.src="time_num_"+h1+".png"; 42 ho2.src="time_num_"+h2+".png"; 43 mi1.src="time_num_"+m1+".png"; 44 mi2.src="time_num_"+m2+".png"; 45 se1.src="time_num_"+s1+".png"; 46 se2.src="time_num_"+s2+".png"; 47 tid=setTimeout("item()",1000); 48 } 49 50 function getId(id){ 51 return document.getElementById(id); 52 } 53 54 function start(){ 55 item(); 56 } 57 58 function stop(){ 59 clearTimeout(tid); 60 } 61 </script> 62 </body> 63 </html>
标签:
原文地址:http://www.cnblogs.com/xiaomume/p/4729069.html