I am trying to select every second table
under a div
.
so my html is like
<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>
I am trying to select every second table under 'tableDiv
' div.
I tried.
$('.tableDiv table:nth-child(even));
but it doesn't work. I can't really change class name or add an ID so it's a bit difficult. Can anyone gives me a hint for it? Thanks a lot!
Use jQuery's
:even
selector.Make sure you close your quote marks. What you started with is fine except for that.