现在的位置: 首页 > 综合 > 正文

Nonove js timer 计时器

2018年04月09日 ⁄ 综合 ⁄ 共 793字 ⁄ 字号 评论关闭
  1. <html> 
  2. <head> 
  3. <title> Nonove js timer 计时器 </title> 
  4. </head> 
  5. <body> 
  6. <script language="javascript"> 
  7. var se,m=0,h=0,s=0,ss=1
  8. function second(){ 
  9. if((ss%100)==0){s+=1;ss=1;} 
  10. if(s>0 && (s%60)==0){m+=1;s=0;} 
  11. if(m>0 && (m%60)==0){h+=1;m=0;} 
  12. t=h+"时"+m+"分"+s+"秒"+ss+"毫秒"; 
  13. document.getElementById("showtime").value=t
  14. ss+=1; 
  15. function startclock(){se=setInterval("second()",1);} 
  16. function pauseclock(){clearInterval(se);} 
  17. function stopclock(){clearInterval(se);ss=1;m=h=s=0;} 
  18. </script> 
  19. <input name="s" type="button" value="开始计时" onclick="startclock()"> 
  20. <input name="s" type="button" value="暂停计时" onclick="pauseclock()"> 
  21. <input name="s" type="button" value="停止计时" onclick="stopclock()"> 
  22.  
  23. <input name="showtime" style="color:#ff0000;width:200px;" id="showtime" type="text" value="0时0分0秒"> 
  24. </body> 
  25. </html> 

 

抱歉!评论已关闭.