Reputation: 2215
<table border="1" class="cssTable">
<tr id="trGroup">
<td>
Black, Total <asp:Label ID="lblCount" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="cssTd">
A
</td>
</tr>
<tr>
<td class="cssTd">
B
</td>
</tr>
<tr id="trGroup">
<td>
White, Total <asp:Label ID="lblCount" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="cssTd">
X
</td>
</tr>
<tr>
<td class="cssTd">
Y
</td>
</tr>
<tr>
<td class="cssTd">
Z
</td>
</tr>
</table>
I have to subtotal group. means in above example Black have 2 Child and White have 3 child
Upvotes: 3
Views: 104
Reputation: 7308
Change the id='trGroup'
to class='trGroup'
(you're supposed to have unique id's), and then use the nextUntil method.
$('.trGroup').each(function () {
var $this = $(this),
subTotal = $this.nextUntil('.trGroup').length;
$this.text($this.text() + subTotal);
});
Upvotes: 3
Reputation: 955
$('#trGroup').each(function() {
var len;
len = $(this).nextUntil('tr#trGroup').length
// i think this **len** is what you require
})
Upvotes: 1