jquery 实现的效果:隔行变色
“`
“` //页面加载,调用js function funx() { pageLoad(); //页面加载,隔行变色 }; //页面加载时,对Table表格移动鼠标行变色操作,通用方法 function pageLoad() { //table 中设置class属性[class= msgtable]
("#msgtable").each(function () { var _this =(this); //设置偶数行和奇数行颜色 _this.find("tr:even").css("background-color", "#d8ebfa");//奇数行 _this.find("tr:odd").css("background-color", "#f0f0f0"); //鼠标移动隔行变色hover用法关键 _this.find("tr:not(:first)").hover(function () {
(this).attr("bColor",
(this).css("background-color")).css("background-color", "#E0E0E0").css("cursor", "pointer"); }, function () {
(this).css("background−color",
(this).attr("bColor")); }); }); }