我要实现 通过复选框 动态的显示和隐藏  表格的相应的列 谢谢!!

解决方案 »

  1.   

    如果是指JS控制DHTML的话,常用办法就是利用style来修改:function setHiddenCol(oTable,iCol) {
     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) {
        oTable.rows[iRow].style.display = (oTable.rows[iRow].style.display == "none")?"block":"none";
    }
    复选框里面,写事件调用第一个函数就行了。
      

  2.   

    document.getElementById("xxx").innerHTML=HTML
      

  3.   

    控制display就行了。类似下面的小例子:
    <html>
    <head>
    <script type="text/javascript" src="jquery-1.4.2.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
    $("#checkboxId").bind("click",function(){
    $("#tr1").css("display","none");
    });
    $("#checkboxId2").bind("click",function(){
    $("#tr1").css("display","block");
    });
    });
    </script>
    </head>
    <body>

    <table style="width: 70%;">
    <tr>
      <td>
    <input id="checkboxId" type="checkbox"/ >
    <label>
    隐藏
    </label>
    <input id="checkboxId2" type="checkbox"/ >
    <label>
    显示
    </label>
    <td>
    </tr>
       </table>

    <table style="width: 70%;">
    <tr  id="tr1">
    <td width=80%>
    <input  type="text" value="隐藏" >
    </td>
    </tr>
    <tr id="tr2">
    <td width=80%>
    <input id="inputId2" type="text" value="显示">
    </td>
    </tr>
    </table>

    </body>
    </html>
      

  4.   

    通过display控制就行了。类似下面的小例子:
    <html>
    <head>
    <script type="text/javascript" src="jquery-1.4.2.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
    $("#checkboxId").bind("click",function(){
    $("#tr1").css("display","none");
    });
    $("#checkboxId2").bind("click",function(){
    $("#tr1").css("display","block");
    });
    });
    </script>
    </head>
    <body>

    <table style="width: 70%;">
    <tr>
      <td>
    <input id="checkboxId" type="checkbox"/ >
    <label>
    隐藏
    </label>
    <input id="checkboxId2" type="checkbox"/ >
    <label>
    显示
    </label>
    <td>
    </tr>
       </table>

    <table style="width: 70%;">
    <tr  id="tr1">
    <td width=80%>
    <input  type="text" value="隐藏" >
    </td>
    </tr>
    <tr id="tr2">
    <td width=80%>
    <input id="inputId2" type="text" value="显示">
    </td>
    </tr>
    </table>

    </body>
    </html>
      

  5.   

    首先谢谢各位 !!
    我想要的是 通过复选框 来隐藏和显示对应表格的列 
     比如说 一共有5个复选框表格就有5列,这是固定了的;  第一个复选框就对应表格的第一列 以此类推
    然后通过点击复选框 来显示和隐藏相应的那一列,用jquery 和css 都可以!!
    再次谢谢 各位了