Thursday, 8 August 2013

Jquery weird issue with the selector

Jquery weird issue with the selector

I have a question from my last post.
How to select second table structure under a div?
I have a new html set and it is like
<div class ='tableDiv'>
<table class='table'>
....
</table>
<table class='table'>
....
</table>
<table class='table'>
....
</table>
</div>
...other stuff...
<div class ='tableDiv'>
<table class='table'>
....
</table>
<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.
from the last post I got.
$('.tableDiv table:even); as my last post answer
However, I now have 3 tables under 'tableDiv' div and the selector seems
to select second table from the first 'tableDiv' and first table on the
second 'tableDiv'
It is very weird as I thought even will select the second one from every div.
Can anyone help me about it? Thanks a lot!

No comments:

Post a Comment