我有一个表,它的行包含选择框。我需要为行提供替代颜色。它几乎完成了。但我的选择框不会改变颜色。它是如何完成的?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