在表上为每个 TD 元素设置的奇数/偶数样式,但由于行跨度而不起作用。 试试 http://jsfiddle.net/eFp7F/61/
CSS 样式:
.tablerow1 td {
background-color:#FFFFFF;
}
.tablerow2 td {
background-color:green;
}
HTML 代码:
<table border="1">
<tr>
<th>Type</th>
<th>Description</th>
<th>Number</th>
</tr>
<tr class="tablerow1">
<td rowspan="1"><p>Cash</p></td>
<td><p>Cash</p></td>
<td><p>00000</p></td>
</tr>
<tr class="tablerow2">
<td rowspan="2"><p>Receivables</p></td>
<td><p>Receivable</p></td>
<td><p>00</p></td>
</tr>
<tr>
<td><p>Accounts</p></td>
<td><p>0</p></td>
</tr>
</table>
如何解决这个问题?
最佳答案
您可以使用 css 交替应用颜色。
.tablerow1 td:nth-child(even) {
background-color:#FFFFFF;
}
.tablerow2 td:nth-child(odd) {
background-color:green;
}
关于jquery - rowspan tablerow 的奇数或偶数颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26279825/