前段时间一同事买了本JQuery实战, 等他看完后,借来翻了下. 以前对于JQuery 只能做到了解 知道 会用. 却没想到JQuery变态的选择器就让我看了好久... 这本书不亏被JQuery之父推荐... 里面写了很多框架级方法, 包括写自己的JQuery插件. 虽然我是一个后台的程序设计.并不涉及前台的东西, 不过还是蛮有收获的. 至少有些东西 比如在给DataView实现光棒效果.
以前要
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { //当鼠标移到的时候设置该行颜色为"#6699CC", 并保存原来的背景颜色 e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699CC'"); //当鼠标移走时还原该行的背景色 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor"); } }
现在只需要写入JS中
$("table tr").bind("mouseover",function(){this.className = 'style';}).bind("mouseout",function(){this.className=''});
这样的话如果想改变光棒颜色,就不需要进入后台修改重新编译了.
==================================================
JQuery最棒的书....~