Jquery-based JavaScript table hover color/recovery, table click color/recovery, click row select checkbox

Source: Internet
Author: User
Tags jquery library

// 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 );
}
});
});
}

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.