在每一个table的最上面用col标签定义宽度。col的使用例子:<HTML> <BODY> <TABLE BORDER="2" RULES="groups"> <!-- RULES is set to "groups", which has no effect in this sample. For this attribute to work, you must use COLSPAN to define the groups of columns.--> <COL SPAN="2" STYLE="color:red"> <COL STYLE="color:blue"> <TR> <TD>This column is in the first group.</TD> <TD>This column is in the first group.</TD> <TD>This column is in the second group.</TD> </TR> <TR> <TD>This column is in the first group.</TD> <TD>This column is in the first group.</TD> <TD>This column is in the second group.</TD> </TR> </TABLE> </BODY> </HTML>
仅隐藏内容<tr style="display:noe">..
完全不显示
<TABLE>
<TR><TD width="100">123</TD><TD width="100">456</TD><TD width="100">789</TD></TR>
<TR><TD>abc</TD><TD>def</TD><TD>ghi</TD></TR>
<TR><TD>jkl</TD><TD>mno</TD><TD>pqr</TD></TR>
</TABLE>
<BR>
<SCRIPT LANGUAGE="JavaScript">
<!--
with(document.all.tags('table')[0].rows[1]){
for (i=0;i<cells.length;i++)
cells[i].width=cells[i].offsetWidth;
}
//-->
</SCRIPT>
<button onclick="with(document.all.tags('table')[0].rows[0].style){display=display==''?'none':''}">test</button>
</BODY>
所以不适宜作设定单元格的宽度,行1
<tr>
<td width=".."></td>
<td width=".."></td>
...
<td width=".."></td>
</tr>----这里设定单元格的宽度,但无内容,行2<tr>
<td>...</td>
<td>...</td>
...
<td>...</td>
</tr>----有内容,行3我想隐藏行2,行3接在行1下面,但宽度设置为行2的设置
<BODY>
<TABLE BORDER="2" RULES="groups">
<!-- RULES is set to "groups", which has no effect in this sample. For this
attribute to work, you must use COLSPAN to define the groups of columns.-->
<COL SPAN="2" STYLE="color:red">
<COL STYLE="color:blue">
<TR>
<TD>This column is in the first group.</TD>
<TD>This column is in the first group.</TD>
<TD>This column is in the second group.</TD>
</TR>
<TR>
<TD>This column is in the first group.</TD>
<TD>This column is in the first group.</TD>
<TD>This column is in the second group.</TD>
</TR>
</TABLE>
</BODY>
</HTML>