我使用的是Twitter Bootstrap v 2.0.1,并且给了我的表格表格条带类。我试图改变行颜色,如果点击。除了每个没有条纹颜色的第n行以外,这种方法非常有效。我认为我需要先删除条纹颜色,但我的尝试失败了。任何想法我失踪?如何从Twitter Bootstrap表中删除背景tr颜色?
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的尝试(S):
<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>
我在做什么错?
这是有道理的...你的建议工作,感谢您的帮助! – user1216398
是否可以使用切换CSS选择器?用户可以定义背景颜色,所以最终我想切换:$(this).find('td').css('background-color','#ff0000'); – user1216398