我正在使用Twitter Bootstrap v 2.0.1,并为我的表提供了 table-striped 类。如果单击,我正在尝试更改行颜色。除了没有条纹颜色的每个 n:th 行之外,这很有效。我假设我需要先删除条纹颜色,但我的尝试失败了。知道我错过了什么吗?
HTML
<table class="table table-bordered table-condensed table-striped">
<thead>
<tr>
<th>Col 1</th>
<th>Col 2</th>
<th>Col 3</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Data 1</strong></td>
<td>Data 2</td>
<td>Data 3</td>
</tr>
<tr>
<td><strong>Data 1</strong></td>
<td>Data 2</td>
<td>Data 3</td>
</tr>
<tr>
<td><strong>Data 1</strong></td>
<td>Data 2</td>
<td>Data 3</td>
</tr>
</tbody>
</table>
我的 jQuery 尝试:
<script type="text/javascript">
$(document).ready(function(){
$('tr').click( function() {
$(this).siblings().removeClass('table-striped');
//$(this).css('background-color', '#ff0000').siblings().removeClass('table-striped');
});
});
</script>
我究竟做错了什么?