i have tr class firstrow and tr class called addrows . addrows class is always after the firstrow class, i want to count the number of addrow tr’s after each firstrow tr . in my example it should be 1 and 6 . this is my code .
<table id="sdx-O_BAR_added" class="roomtypeadded">
<tbody>
<tr class="header">
</tr>
<tr class="header">
</tr>
<tr class="firstrow">
</tr>
<tr class="addrows">
</tr>
<tr class="header">
</tr>
<tr class="header">
</tr>
<tr class="firstrow">
</tr>
<tr class="addrows">
</tr>
<tr class="addrows">
</tr>
<tr class="addrows">
</tr>
<tr class="addrows">
</tr>
<tr class="addrows">
</tr>
<tr class="addrows">
</tr>
</tbody>
</table>
i have no idea how to this , i tried with jquery siblings() and next() . but coud not do it , please help . 🙁
You could try the
$.nextAll()function:This will give you the total count of all rows that follow a
tr.firstrowelement.If you want to get an array of each
tr.firstrow‘s following .addrows class elements, you’d probably find jQuery’s$.map()function more useful:This will return an array of numbers – effectively subtotals (e.g. [1, 6]).