• <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>
  • 相关阅读:
    符瑞艺 160809228_C语言程序设计实验2 选择结构程序设计
    页面布局class常见命名规范
    CSS学习笔记
    HTML学习笔记
    虚拟机Centos7设置ip地址,并ping真机ip
    vue单页面开发和多页面开发的概念,及优缺点?
    传统的DOM渲染方式?
    面试题
    通过电脑chrome调试手机真机打开的微信H5页面,调试电脑微信H5页面(转载自 乐乐熊小妹)
    常见前端面试题及答案
  • 原文地址:https://www.cnblogs.com/keygle/p/2271687.html
Copyright © 2020-2023  润新知