javascript - Subtotal Group using jquery -
<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"> </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 subtotal group. means in above example black have 2 child , white have 3 child
change id='trgroup'
class='trgroup'
(you're supposed have unique id's), , use nextuntil method.
$('.trgroup').each(function () { var $this = $(this), subtotal = $this.nextuntil('.trgroup').length; $this.text($this.text() + subtotal); });
Comments
Post a Comment