I'm not quite a jQuery universe yet, so I ask for it in the hope that someone can strike him.
I use jQuery templates to create a table with rows based on nested dictionaries (they are nested in 5 layers in depth or so). It is based on data on organizational structure and people in each group. What I intend to do, based on the partial code below, for each line of the command, is to get the line of "persons" belonging to this command. Here is what I have indented for readability.
<tr class="division">...</tr>
<tr class="team">...</tr>
<tr class="person">...</tr>
<tr class="person">...</tr>
<tr class="team">...</tr>
<tr class="person">...</tr>
<tr class="person">...</tr>
<tr class="person">...</tr>
<tr class="division">...</tr>
<tr class="team">...</tr>
Now I have a jQuery selector that gets all the rows class="team"
, and then for each row I try to find a selector to get every next row class="person"
until the next row person
. I can not understand. Something to look for instead of a method .nextAll()
?
$('table tr.team').each(function () {
var personRows = $(this).nextUntil('tr.team');
console.log('row count: ' + personRows.length);
});
I am now logging into the console, so the console output for the HTML above should match what ...
> row count: 2
> row count: 3
Unfortunately, I get something more consistent with this, because of this "division"
-class line .
> row count: 2
> row count: 4
I am trying to test the API to get what I want, but I cannot get the desired effect. Any ideas? Any nifty solutions? Should I use a clause if
somewhere to determine if the string is the one that I want to include in my selector?