Example of selecting selected rows and columns using jquery _ jquery-js tutorial

Source: Internet
Author: User
This article mainly introduces how jquery implements the example of select selected rows and column total. For more information, see the Jquery method.

The Code is as follows:


$ (
Function (){

// Calculate the total value of the personnel statistical table during page loading
CalcSum ();

});

// Calculates the total number of rows.
/*
Aggregate behavior intermediate Variables
Add each cell to the total row of the column
Obtain the total number of columns.
*/
Function trVisible (chk, index ){

Var disValue = $ ("# Tr" + index.html .css ("display ");
If (chk. checked ){

$ ("# Tr" + index.html .css ("display", "block ");
}
Else {
$ ("# Tr" + index.html .css ("display", "none ");
}
CalcSum ();
}
Function calcSum (){

// The total row has 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 = require (this).css ("display ");
// Hide rows not involved 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

The Code is as follows:













Branch
China South Branch
Sheet 1 Zhang 2 Zhang 3 Figure 4 Sheet 5 Zhang 6


























































Sheet 1 124536 124536 124536 124536 124536 124536 124536 124536 124536 124536
Zhang 2 124536 124536 124536 124536 124536 124536 124536 124536 124536 124536
Zhang 23 124536 124536 124536 124536 124536 124536 124536 124536 124536 124536
0 0 0 0 0 0 0 0 0 0

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.