Jquery实现列表(隔行换色,全选,鼠标滑过当前行)效果实例
更新时间:2013年06月09日 16:42:12 作者:
Jquery实现列表(隔行换色,全选,鼠标滑过当前行)效果实例,需要的朋友可以参考一下
[javascript]
$(function () {
gridview("GridView1");
});
//gridview
function gridview(objgridview) {
//get obj id
var gridviewId = "#" + objgridview;
//even
$(gridviewId + ">tbody tr:even").addClass("NormalColor");
//first
$(gridviewId + ">tbody tr:first").removeClass("NormalColor").addClass("HeadColor");
//odd
$(gridviewId + ">tbody tr:odd").addClass("AlterColor");
//move and click
$(gridviewId + ">tbody tr").slice(1).hover(function () {
$(this).addClass("HoverColor");
}, function () {
$(this).removeClass("HoverColor");
});
//all check
$("#chkAll").click(function () {
$(gridviewId + '>tbody >tr >td >input:checkbox').attr('checked', this.checked);
});
//check status
$(gridviewId + ' >tbody >tr >td >input:checkbox').click(function () {
var expr1 = gridviewId + ' >tbody >tr >td >input:checkbox:checked';
var expr2 = gridviewId + ' >tbody >tr >td >input:checkbox';
var selectAll = $(expr1).length == $(expr2).length;
$('#chkAll').attr('checked', selectAll);
});
}
[html]
<asp:GridView ID="GridView1" runat="server" ClientIDMode="Static" Width="100%" CssClass="gvCss">
<Columns>
<asp:TemplateField>
lt;HeaderTemplate>
<input type="checkbox" id="chkAll" name="chkAll" />
lt;/HeaderTemplate>
<ItemTemplate>
<input type="checkbox" id="chkItem" name="chkItem" value='<%# Eval("ID") %>' />
</ItemTemplate>
</asp:TemplateField>
</asp:GridView>
[css]
.HeadColor{background-color: #E0ECFF; color:#333;line-height:25px;}
.AlterColor{background-color: #edf1f8; line-height:20px;}
.NormalColor{background-color: #f7f6f3; line-height:20px;}
.HoverColor{background: #89A5D1; line-height:20px;}
.SelectColor{background-color: #ACBFDF; line-height:20px;}
复制代码 代码如下:
$(function () {
gridview("GridView1");
});
//gridview
function gridview(objgridview) {
//get obj id
var gridviewId = "#" + objgridview;
//even
$(gridviewId + ">tbody tr:even").addClass("NormalColor");
//first
$(gridviewId + ">tbody tr:first").removeClass("NormalColor").addClass("HeadColor");
//odd
$(gridviewId + ">tbody tr:odd").addClass("AlterColor");
//move and click
$(gridviewId + ">tbody tr").slice(1).hover(function () {
$(this).addClass("HoverColor");
}, function () {
$(this).removeClass("HoverColor");
});
//all check
$("#chkAll").click(function () {
$(gridviewId + '>tbody >tr >td >input:checkbox').attr('checked', this.checked);
});
//check status
$(gridviewId + ' >tbody >tr >td >input:checkbox').click(function () {
var expr1 = gridviewId + ' >tbody >tr >td >input:checkbox:checked';
var expr2 = gridviewId + ' >tbody >tr >td >input:checkbox';
var selectAll = $(expr1).length == $(expr2).length;
$('#chkAll').attr('checked', selectAll);
});
}
[html]
复制代码 代码如下:
<asp:GridView ID="GridView1" runat="server" ClientIDMode="Static" Width="100%" CssClass="gvCss">
<Columns>
<asp:TemplateField>
lt;HeaderTemplate>
<input type="checkbox" id="chkAll" name="chkAll" />
lt;/HeaderTemplate>
<ItemTemplate>
<input type="checkbox" id="chkItem" name="chkItem" value='<%# Eval("ID") %>' />
</ItemTemplate>
</asp:TemplateField>
</asp:GridView>
[css]
复制代码 代码如下:
.HeadColor{background-color: #E0ECFF; color:#333;line-height:25px;}
.AlterColor{background-color: #edf1f8; line-height:20px;}
.NormalColor{background-color: #f7f6f3; line-height:20px;}
.HoverColor{background: #89A5D1; line-height:20px;}
.SelectColor{background-color: #ACBFDF; line-height:20px;}
相关文章
jQuery插件Elastislide实现响应式的焦点图无缝滚动切换特效
这篇文章主要介绍了jQuery插件Elastislide实现响应式的焦点图无缝滚动切换特效,效果非常的棒,而且兼容性也很好,推荐给小伙伴们2015-04-04
js页面滚动时层智能浮动定位实现(jQuery/MooTools)
关于层的智能浮动效果早在几年前我就在国外的一些个人网站的垂直导航上见到了,现在似乎在国内一些商业网站上也屡见此效果2011-08-08
jQuery使用$.extend(true,object1, object2);实现深拷贝对象的方法分析
这篇文章主要介绍了jQuery使用$.extend(true,object1, object2);实现深拷贝对象的方法,结合实例形式分析了jQuery中$.extend(true,object1, object2);进行深拷贝操作相关实现技巧,需要的朋友可以参考下2019-03-03


最新评论