Heim  >  Artikel  >  Web-Frontend  >  jquery实现select选中行、列合计示例_jquery

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

WBOY
WBOYOriginal
2016-05-16 16:51:111013Durchsuche

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


Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn