Wednesday, 21 August 2013

Get Sum of 2nd in every in Table

Get Sum of 2nd in every in Table

I want to calculate the sum of the 2nd item in each of the rows and sum
the total into my div.
My JS is as follows
$('.table tbody tr:gt(0)').each(function () {
var mixTotal = parseInt($(this).find('td:nth(2)').html());
// Add total to div
$('.totals').text(mixTotal);
});
DEMO HERE http://jsfiddle.net/5pnMh/1/
My Html is a standard HTML table, which contains a thead tbody and tfoot.
I can't seem to get it to work. I can get each value but not sure how to
add them.
Looking for some help

No comments:

Post a Comment