日期:2014-05-16 浏览次数:20347 次
<!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> 援引博客:http://hi.baidu.com/gaomode/blog/item/084fff606789a2dc8db10dc0.html