zoukankan      html  css  js  c++  java
  • javascript学习

    html:

    <html>

       <head>

          <script src="text.js">    //链接javas

      </head>

    <body onload="startTime()">    调用javascript中的startTime()方法

               <div id="header">
                   
                    <!--超链接-->
                    <a title="百度一下你就知道" href="http://www.baidu.com">百度一下你就知道</a>
                    <input type="button" onclick="changecolor()" value="changecolor"/>
                    <div id="txt">
                    </div>
                </div>

    </html>

    javascript:

               //改变id为header的背景颜色为黑色

               function changecolor()
              {
                     $('header').style.backgroundColor = 'black';
              }
               function $(id)
             {
                      return document.getElementById(id);
             }

              //显示一个时钟在header里

              function startTime()
            {
                       var today=new Date()
                       var h=today.getHours()//得到当前的小时
                       var m=today.getMinutes()//得到当前的分钟
                       var s=today.getSeconds()//得到当前的秒数
                      // add a zero in front of numbers<10
                      m=checkTime(m)
                      s=checkTime(s)
                      document.getElementById('txt').innerHTML=h+":"+m+":"+s
                      t=setTimeout('startTime()',500)每隔0.5秒执行一次startTime()方法
             }

              //如果分钟和秒数的数字没有超过10前一位的位置用0补充
              function checkTime(i)
            {
                      if (i<10)
                      {i="0" + i}
                       return i
              }

  • 相关阅读:
    ACE反应器(Reactor)模式(1)
    net 命令
    ACE反应器(Reactor)模式(2)
    恢复SQLServer实例连接 (转载)
    在SQL Server Management Studio中可以运行作业但是用TSQL运行则失败 (转载)
    VirtualBox 之 共享磁盘
    从 IClassFactory 为 CLSID 为 {0002450000000000C000000000000046} 的 COM 组件创建实例失败,原因是出现以下错误: 8001010a解决办法 .
    SQLServer数据类型优先级对性能的影响 (转)
    封装getElementsByAttribute
    js中setAttribute 的兼容性
  • 原文地址:https://www.cnblogs.com/liushuang/p/2862278.html
Copyright © 2011-2022 走看看