現在、このコードを使用して、テーブルの列から合計を計算しています:
function calculateTotals() {
//these will hold the totals
var hours = 0;
//reference the rows you want to add
//this will not include the header row
var rows = $("#deliverables tr:not(:first-child, :last-child)");
rows.children("td:nth-child(2)").each(function() {
hours += parseInt($(this).html());
});
midHours = (hours).toFixed(2);
$(".total-hours").html(midHours);
};
ただし、出力midHours
には小数は表示されません。たとえば、値が 12.5 のテーブル セルの場合、セルでは 12 として出力されます.total-hours
。