Home  >  Article  >  Web Front-end  >  Example of jquery implementation of select selected rows and columns_jquery

Example of jquery implementation of select selected rows and columns_jquery

WBOY
WBOYOriginal
2016-05-16 16:51:111054browse

Jquery method

Copy code The code is as follows:

$(
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
Copy code The code is as follows:












分公司

张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


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn