JQuery-based javascript table hover color/recovery, table click color/recovery, click row select Checkbox

Source: Internet
Author: User

// Version 1.0
// Date: 2007/08/01
// Remarks: jQuery library is required
// Reference: Dodo (tableRowCheckboxToggle) and softcomplex (tigra_tables)

Function Kin_Tables (
Kin_Table_GetTableMethod, // The method for getting the Table is the same as the $ () function required Parameter
Kin_Table_Header_Offset, // number of rows ignored from the beginning. Optional Parameter
Kin_Table_Footer_Offset, // number of rows ignored from the end. Optional Parameter
Kin_Table_Odd_Style, // an optional parameter for an odd row style
Kin_Table_Even_Style, // optional parameter of the even row style
Kin_Table_Hover_Style, // optional parameter of the mouse hover Style
Kin_Table_Click_Style // optional parameter of the mouse clicking Style
){

$ (Function (){
Var Kin_Table_Config = [];
Kin_Table_Config.GetTableMethod = (Kin_Table_GetTableMethod? Kin_Table_GetTableMethod: ". Kin_Table ");
Kin_Table_Config.Header_Offset = (! IsNaN (Kin_Table_Header_Offset )? Kin_Table_Header_Offset: 0 );
Kin_Table_Config.Footer_Offset = (! IsNaN (Kin_Table_Footer_Offset )? Kin_Table_Footer_Offset: 0 );
Kin_Table_Config.Odd_Style = (Kin_Table_Odd_Style? Kin_Table_Odd_Style: "odd ");
Kin_Table_Config.Even_Style = (Kin_Table_Even_Style? Kin_Table_Even_Style: "even ");
Kin_Table_Config.Hover_Style = (Kin_Table_Hover_Style? Kin_Table_Hover_Style: "over ");
Kin_Table_Config.Click_Style = (Kin_Table_Click_Style? Kin_Table_Click_Style: "clicked ");

Var Kin_Table = $ (Kin_Table_Config.GetTableMethod + "tr: nth-child (n +" + eval (Kin_Table_Config.Header_Offset + 1) + ")");

Kin_Table.each (function (I, row ){
If (I> = Kin_Table.length-Kin_Table_Config.Footer_Offset) return false;
Var Kin_Table_Row_Checkbox = $ (row). find (": checkbox ");
BChecked = false;
$ (Row). addClass (I % 2 = 0? Kin_Table_Config.Odd_Style: Kin_Table_Config.Even_Style)
$ (Row). hover (
Function () {$ (this). addClass (Kin_Table_Config.Hover_Style );},
Function () {$ (this). removeClass (Kin_Table_Config.Hover_Style );
});
$ (Row). click (function (){
$ (This). toggleClass (Kin_Table_Config.Click_Style );
Kin_Table_Row_Checkbox.each (function (){
This. checked = $ (row). hasClass (Kin_Table_Config.Click_Style );
});
});
Kin_Table_Row_Checkbox.each (function (){
If (this. checked ){
BChecked = true;
Return false;
}
});
If (bChecked ){
$ (Row). addClass (Kin_Table_Config.Click_Style );
Kin_Table_Row_Checkbox.each (function (){
This. checked = true;
});
} Else {
$ (Row). removeClass (Kin_Table_Config.Click_Style );
}
});
});
}

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.