当前位置:Gxlcms > JavaScript > jquery实现select选中行、列合计示例_jquery

jquery实现select选中行、列合计示例_jquery

时间:2021-07-01 10:21:17 帮助过:26人阅读

Jquery 方法
代码如下:

$(
function () {

//页面加载时计算人员统计表合计值
calcSum();

});

//合计行计算
/*
以合计行为中间变量
每个单元格与该列合计行相加
得到每列合计
*/
function trVisible(chk, index) {

var disValue = $("#Tr" + index).css("display");
if (chk.checked) {

$("#Tr" + index).css("display", "block");
}
else {
$("#Tr" + index).css("display", "none");
}
calcSum();
}
function calcSum() {

//合计行赋初始值0
$("#trSum").each(function () {
$(this).find("td").each(function () {
if ($(this).index() != 0) {
$(this).text("0");
}
});
});

$("#tabrytj").find("tr").each(function () {
var trDis = $(this).css("display");
//隐藏行不参与计算
if (trDis == "block") {
$(this).find("td").each(function () {
var index = $(this).index();
if (index >= 1) {
var tdValue = $("#trSum").find("td:eq(" + index + ")").text();
//totalSum += parseFloat($(this).text());
$("#trSum").find("td:eq(" + index + ")").text(parseFloat(tdValue) + parseFloat($(this).text()));
}
});
}
});


}

html语句
代码如下:












分公司

张1 张2 张3 张4 张5 张6


























































张1 124536 124536 124536 124536 124536 124536 124536 124536 124536 124536
张2 124536 124536 124536 124536 124536 124536 124536 124536 124536 124536
张23 124536 124536 124536 124536 124536 124536 124536 124536 124536 124536
0 0 0 0 0 0 0 0 0 0


人气教程排行