Kin_Tables 介绍
/***********
Name: Kin_Table
Website: http://jorkin.reallydo.com/article.asp?id=538
Version: 1.0
Update: 2007/08/05
Introduction: toggle table row color by mouSEOver
and check checkBox by click table row
and toggle table row background-color by check checkBox
but can not exclude checkBoxes (I dont need this. ^_^ )
Reference: Dodo (tableRowCheckBoxToggle)
Softcomplex (tigra_tables)
Others:Need jQuery
************/
function Kin_Tables(Kin_Table_GetTableMethod, //get your table
Kin_Table_Header_Offset, //set the table header offset
Kin_Table_Footer_Offset, //set the table footer offset
Kin_Table_Odd_Style, // set the table odd row style name (Default:odd)
Kin_Table_Even_Style, // set the table even row style name (Default:even)
Kin_Table_Hover_Style, // set the table mouSEOver row style name
(Default:over)
Kin_Table_Click_Style // set the table odd row style name (Default:clicked)
){
- $(function(){
- var Kin_Table_Config = [];
- Kin_Table_Config.GetTableMethod = (Kin_Table_GetTableMethod ?
- Kin_Table_GetTableMethod : “.Kin_Table”); //得到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)+”)”); //Old Method
var Kin_Table = $(Kin_Table_Config.GetTableMethod + “
tr”).slice(Kin_Table_Config.Header_Offset,-Kin_Table_Config.Footer_Offset);
//New Method
Kin_Table.each(function(i, row){
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);
}
});
});
}
Kin_Tables 官网
http://plugins.jquery.com/project/Kin_Tables
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。