首頁  >  文章  >  web前端  >  jquery实现select选中行、列合计示例_jquery

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

WBOY
WBOY原創
2016-05-16 16:51:111013瀏覽

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


陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn