Fiddle
<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
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);
});
DEMO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With