JQuery求和函数

时间:2014-05-06 09:38:17   收藏:0   阅读:1838

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);
}
});

JQuery求和函数,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!