我想在table
下选择每一秒div
。
所以我的HTML就像
<div class ='tableDiv'>
<table class='table'>
....
</table>
<table class='table'>
....
</table>
</div>
...other stuff...
<div class ='tableDiv'>
<table class='table'>
....
</table>
<table class='table'>
....
</table>
</div>
other stuff
<div class ='anotherTableDiv'>
<table class='table'>
....
</table>
<table class='table'>
....
</table>
</div>
我正在尝试选择“tableDiv
”div下的每个第二个表格。
我试过了。
$('.tableDiv table:nth-child(even));
但它不起作用。我无法真正更改类名或添加ID,因此有点困难。任何人都可以给我一个暗示吗?非常感谢!
答案 0 :(得分:2)
使用jQuery的:even
选择器。
$('.tableDiv table:even')
答案 1 :(得分:2)
确保关闭引号。除此之外,你开始的很好。