function convert2Int(num) {
num = parseInt(num);
return isNaN(num) ? 0 : num;
}
$(function () {
var rows = $("#saleTable tr").length - 1;
var columns = $("#saleTable tr td").length / rows;
//alert($("#saleTable tr:eq(2) td:eq(0)").html());
for (var j = 0; j < columns; j++) {
var tempResult = 0;
for (var i = 1; i <
rows; i++) {
// alert($("#saleTable
tr:eq(" + i + ") td:eq(" + j + ")").html());
tempResult += convert2Int($("#saleTable tr:eq(" + i + ") td:eq(" + j +
")").html());
}
$("#saleTable tr:eq(" + rows + ") td:eq(" + j + ")").html(tempResult);
}
});
时间: 2024-10-12 20:10:29