zoukankan      html  css  js  c++  java
  • js如何隐藏表格的行与列

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
        <title>显示隐藏列 </title>

        <script language="JavaScript">

            function setHiddenCol(oTable, iCol)//Writed by QQ:190988779 at 2007-7-24 11:14:09   
            {
                for (i = 0; i < oTable.rows.length; i++) {
                    oTable.rows[i].cells[iCol].style.display = oTable.rows[i].cells[iCol].style.display == "none" ? "block" : "none";
                }
            }
            function setHiddenRow(oTable, iRow)//Writed by QQ:190988779 at 2007-7-24 11:14:09   
            {
                oTable.rows[iRow].style.display = oTable.rows[iRow].style.display == "none" ? "block" : "none";
            }   
      
        </script>

    </head>
    <body>
        <table id="Table1" cellspacing="1" cellpadding="1" border="1">
            <tr>
                <td width="20%">
                    00
                </td>
                <td width="20%" bgcolor="#E3E3E3">
                    01
                </td>
                <td width="20%">
                    02
                </td>
            </tr>
            <tr>
                <td width="20%" bgcolor="red">
                    10
                </td>
                <td width="20%" bgcolor="green">
                    11
                </td>
                <td width="20%" bgcolor="red">
                    12
                </td>
            </tr>
            <tr>
                <td width="20%">
                    20
                </td>
                <td width="20%" bgcolor="#E3E3E3">
                    21
                </td>
                <td width="20%">
                    22
                </td>
            </tr>
        </table>
        </P>
        <input id="btnHiddenCol" type="button" value="显示/隐藏第2列" name="btnHiddenCol" onclick="setHiddenCol(document.getElementById('Table1'),1)">
        <input id="btnHiddenRow" type="button" value="显示/隐藏第2行" name="btnHiddenRow" onclick="setHiddenRow(document.getElementById('Table1'),1)">
    </body>
    </html>

  • 相关阅读:
    ZOJ 3327 Friend Number
    ZOJ 3324 Machine
    2010-2011 ACM-ICPC, NEERC, Southern Subregional Contest C Explode 'Em All
    UVA 12594 Naming Babies
    POJ 3709 K-Anonymous Sequence
    POJ 1180 Batch Scheduling
    POJ 1160 Post Office
    HDU 3516 Tree Construction
    HDU 3045 Picnic Cows
    UVALive 5097 Cross the Wall
  • 原文地址:https://www.cnblogs.com/aaa6818162/p/2193231.html
Copyright © 2011-2022 走看看