码迷,mamicode.com
首页 > Web开发 > 详细

js时钟

时间:2014-11-21 18:39:13      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   ar   color   sp   java   for   

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>shizhong</title>
    <script language="javascript" >; function disptime() {  
        var time=new Date();  var hour=time.getHours();  
        var minute=time.getMinutes();  
        var second=time.getSeconds();   
        /*先来判断下 是上午还是下午*/   
        var am="AM";  
        if(hour>12){   
            hour=hour-12;  
             am="PM";   
             }   
        /*判断是不是要前置补零,一般情况下补零*/ 
         if(minute<10)   
             minute="0"+minute;     
         if(second<10)  
          second="0"+second;  
         document.myform.myclock.value=hour+":"+minute+":"+second;  
         var Mytime=setTimeout("disptime()",1000); }  </script></head>
<body onload="disptime()">
    <form name="myform">
        <div align="15">
            <input type="text" name="myclock" value="" size="15"></div>
    </form>
</body>
</html>

 

js时钟

标签:style   blog   http   io   ar   color   sp   java   for   

原文地址:http://www.cnblogs.com/JAYIT/p/4113457.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!