• 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
              }

  • 相关阅读:
    ssh认证
    Nginx中proxy_pass 后有无/的区别
    Nginx中$http_host、$host、$proxy_host的区别
    Nginx读书笔记----HTTP proxy module
    ngx_http_core_module模块提供的变量
    Nginx读书笔记三----资源分配
    http_code 413 Request Entity Too Large
    nginx读书笔记二----nginx配置
    firewall-cmd命令
    GCC编译器原理(一)03------GCC 工具:gprof、ld、libbfd、libiberty 和libopcodes
  • 原文地址:https://www.cnblogs.com/liushuang/p/2862278.html
Copyright © 2020-2023  润新知