1$(function() {
2 $("#subtotal").html(sumColumn(4));
3 $("#total").html(sumColumn(5));
4});
5
6function sumColumn(index) {
7 var total = 0;
8 $("td:nth-child(" + index + ")").each(function() {
9 total += parseInt($(this).text(), 10) || 0;
10 });
11 return total;
12}
13<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
14<table style="border-spacing: 10px;">
15 <tr>
16 <td>ClientName</td>
17 <td>ItemName</td>
18 <td>Quantity</td>
19 <td>12</td>
20 <td>34</td>
21 </tr>
22 <tr>
23 <td>ClientName</td>
24 <td>ItemName</td>
25 <td>Quantity</td>
26 <td>56</td>
27 <td>78</td>
28 </tr>
29 <tr>
30 <td>ClientName</td>
31 <td>ItemName</td>
32 <td>Quantity</td>
33 <td>90</td>
34 <td>12</td>
35 </tr>
36 <tr>
37 <td colspan="3">Totals</td>
38 <td id="subtotal"></td>
39 <td id="total"></td>
40 </tr>
41</table>