怎么通过复选框动态的改变列 我要实现 通过复选框 动态的显示和隐藏 表格的相应的列 谢谢!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 如果是指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";}复选框里面,写事件调用第一个函数就行了。 document.getElementById("xxx").innerHTML=HTML 控制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> 通过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列,这是固定了的; 第一个复选框就对应表格的第一列 以此类推然后通过点击复选框 来显示和隐藏相应的那一列,用jquery 和css 都可以!!再次谢谢 各位了 问一个java模拟钢琴音的问题 action不能跳转 struts2param标签value中文乱码问题 求上传附件的大小 用POI建立Excel,设置页眉时,用HSSFHeader中文字会显示乱码 jsp里如何实现pageload()事件 求助一个简单的问题 在线等待关于类成员的问题 com.jspsmart.upload 这个类在哪里?jdk?jsp?服务器?或者别的地方? 说一说如何做到JSP同时支持简、繁体的思路,最好有代码!谢谢! java 动态加载报找不到接口 各方大神,帮忙看看,怎么看源码的问题
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";
}
复选框里面,写事件调用第一个函数就行了。
<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>
<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列,这是固定了的; 第一个复选框就对应表格的第一列 以此类推
然后通过点击复选框 来显示和隐藏相应的那一列,用jquery 和css 都可以!!
再次谢谢 各位了