我有一個表,它的行包含選擇框。我需要爲行提供替代顏色。它幾乎完成了。但我的選擇框不會改變顏色。它是如何完成的?Bgcolor替代行包含選擇框動態使用jQuery
HTML
<table width="100%" cellpadding="0" cellspacing="0" border="0"
class="stdform">
..other codes...
<tr><td>
<table class="fancyTable" id="sortable-table"
cellpadding="0" cellspacing="0" width="100%">
<thead>
<tr>
<td>header one</td>
<td><select><option>--select--</option></select></td>
<td>header three</td>
</tr>
</thead>
<tbody id="job-tbody">
<tr class="prototype">
<td>one</td>
<td><select><option>--select--</option></select></td>
<td>three</td>
</tr>
</tbody>
</table>
</td></tr>
</table>
CSS:
$(document).ready(function() {
$("tr:odd").css("background-color","#eee");
$("tr:even").css("background-color","#ddd");
});
FIDDLE: http://jsfiddle.net/wk7Dy/15/
你可以只用CSS爲此,請參閱http://stackoverflow.com/questions/5080699/using-css-even-and-odd-pseudo-classes-with-list- items – Robert