Jquery method
$(
function () {
//Calculate the total value of the personnel statistics table when the page is loaded
calcSum();
});
//Calculate the total row
/*
Use the total row as an intermediate variable
Add each cell to the total row of the column
Get the total of each column
*/
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() {
//The total row is assigned an initial value of 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");
//Hidden rows do not participate in calculation
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 statement
张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 |