这是我的 html 代码:http://jsfiddle.net/Udxyb/417/
在上面的代码中,我在第一个 tr 中有四列(例如:第 1 节、第 2 节、第 3 节、第 4 节)。但是在我的表格的下一个 tr 中,我想要 8 列与第一个 tr 宽度相同的列(例如:item 111、元素 112、元素 113、元素 114、元素 115、元素 116、元素 117、元素 118)。
<table id="main_table">
<thead>
<tr class="firstline">
<th>Column1</th>
<th>Column2</th>
<th>Column3</th>
<th>Column4</th>
</tr>
</thead>
<tbody>
<tr style="width:1002px; background-color:green; color:white">
<td colspan="" class="flip"> Section 1 </td>
<td colspan="" class="flip"> Section 2 </td>
<td colspan="" class="flip"> Section 3 </td>
<td colspan="" class="flip"> Section 4 </td>
</tr>
</tbody>
<tbody class="section">
<tr>
<td>item 111</td>
<td>item 112</td>
<td>item 113</td>
<td>item 114</td>
<td>item 115</td>
<td>item 116</td>
<td>item 117</td>
<td>item 118</td>
</tr>
<tr>
<td>item 121</td>
<td>item 122</td>
<td>item 123</td>
<td>item 124</td>
</tr>
<tr>
<td>item 131</td>
<td>item 132</td>
<td>item 133</td>
<td>item 134</td>
</tr>
</tbody>
<tbody>
<tr style="background-color:green; color:white">
<td colspan="" class="flip"> Section 1 </td>
<td colspan="" class="flip"> Section 2 </td>
<td colspan="" class="flip"> Section 3 </td> <td colspan="" class="flip"> Section 4 </td>
</tr>
</tbody>
<tbody class="section">
<tr>
<td>item 211</td>
<td>item 212</td>
<td>item 213</td>
<td>item 214</td>
</tr>
<tr>
<td>item 221</td>
<td>item 222</td>
<td>item 223</td>
<td>item 224</td>
</tr>
<tr>
<td>item 231</td>
<td>item 232</td>
<td>item 233</td>
<td>item 234</td>
</tr>
</tbody>
<tbody>
<tr style="background-color:green; color:white">
<td colspan="" class="flip"> Section 1 </td>
<td colspan="" class="flip"> Section 2 </td>
<td colspan="" class="flip"> Section 3 </td>
<td colspan="" class="flip"> Section 4 </td>
</tr>
</tbody>
<tbody class="section">
<tr>
<td>item 311</td>
<td>item 312</td>
<td>item 313</td>
<td>item 314</td>
</tr>
<tr>
<td>item 321</td>
<td>item 322</td>
<td>item 323</td>
<td>item 324</td>
</tr>
<tr>
<td>item 331</td>
<td>item 332</td>
<td>item 333</td>
<td>item 334</td>
</tr>
</tbody>
</table>
这是我的 jquery 代码:
jQuery(function($) {
$("#polls").on("click", ".flip", function() {
$(this)
.closest('tbody')
.next('.section')
.toggle('fast');
});
});
最佳答案
在具有四个单元格的行中的所有单元格上设置 colspan="2"
。
关于javascript - 如何在我的第二个 tr 中获得 8 列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22298365/