JavaScript based on jquery table hover color/restore, table click Color/restore, click Line Selection checkbox_jquery

Source: Internet
Author: User
Tags jquery library
Version: 1.0
Date: 2007/08/01
Note: Need jquery library
References: Dodo (Tablerowcheckboxtoggle) and Softcomplex (Tigra_tables)

function Kin_tables (
Kin_table_gettablemethod,//Get Table method with $ () function required Parameters
Kin_table_header_offset,//How many rows of optional parameters have been ignored in the past
Kin_table_footer_offset,//How many rows to ignore from the beginning? Optional parameters
Kin_table_odd_style,//odd line style optional parameter
Kin_table_even_style,//even row style optional parameter
Kin_table_hover_style,//mouse hover style optional parameters
Kin_table_click_style//mouse click style Optional Parameters
){

$ (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.