javascript 隐藏table的某一列
try
<script language="javascript">
var bVisible = true;
function DisplayColumn(nCol)
{
var rows = document.all("tbl").rows;
for (var i=0; i < rows.length; i++)
if (rows[i].cells.length > nCol)
rows[i].cells[nCol].style.display = bVisible ? "none" : "";
bVisible = !bVisible ;
}
</script>
<table id="tbl" border="1" cellspacing="0" cellpaddin="0">
<thead><th>head 1</th><th>head 2</th><th>head 3</th></thead>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
</table>
<input type="button" value="Show/Hide Column 2" onclick="DisplayColumn(1);">
<script language="javascript">
var bVisible = true;
function DisplayColumn(nCol)
{
var rows = document.all("tbl").rows;
for (var i=0; i < rows.length; i++)
if (rows[i].cells.length > nCol)
rows[i].cells[nCol].style.display = bVisible ? "none" : "";
bVisible = !bVisible ;
}
</script>
<table id="tbl" border="1" cellspacing="0" cellpaddin="0">
<thead><th>head 1</th><th>head 2</th><th>head 3</th></thead>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr>
</table>
<input type="button" value="Show/Hide Column 2" onclick="DisplayColumn(1);">