zoukankan      html  css  js  c++  java
  • <javascript学习笔记>javascript 实现隔行变色

    <script type="text/javascript">
    window.onload = function()//javascript 实现隔行变色
    {

    var myCaption = document.getElementsByTagName('caption')[0];
    myCaption.style.backgroundColor = "red";
    var myTable = document.getElementById("myTable");
    myTable.style.border = "solid"
    //alert(typeof myTable);
    var myTrs = myTable.getElementsByTagName('tr');
    //alert(myTrs.length);
    for(var i = 0; i<myTrs.length;i++)
    {
    if(i%2 == 0)
    {
    myTrs[i].style.backgroundColor ="pink";
    }else
    {
    myTrs[i].style.backgroundColor ="white";
    }
    }

    }

    </script>
    </head>
    <body>
    <table id="myTable" align="center" style="80%">
    <caption>javascript 实现隔行变色</caption>
    <tr><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td></tr>
    <tr><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td></tr>
    <tr><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td></tr>
    <tr><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td></tr>
    <tr><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td></tr>
    <tr><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td></tr>
    <tr><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td></tr>
    <tr><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td></tr>
    <tr><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td></tr>
    <tr><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td></tr>
    <tr><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td><td>aaaa</td></tr>
    </table>
    </body>
    </html>
  • 相关阅读:
    python __builtins__ credits类 (15)
    python __builtins__ copyright类 (14)
    python __builtins__ complex类 (13)
    Map 遍历
    Java后台JSON数据的使用
    oracle增加表空间的四种方法
    Oracle ORA-12541:TNS:无监听程序
    Exception
    Spring 配置数据源
    在web.xml中classpath和classpath*的区别
  • 原文地址:https://www.cnblogs.com/keygle/p/2271687.html
Copyright © 2011-2022 走看看