//鼠标移上去tr变色
(function($) {
$.fn.hightlightTR = function(options) {
var defaults = {
backgroundColor: "#006AA6", //原来的背景色
highlightColor: "black", //高亮背景色
hasHeader: true,//是否有表头
hasTail: true,//是否有表尾
originColor: "#bbbbbb", //原来的边框色
affectBorder: true //是否影响Border
}
var options = $.extend(defaults, options);
this.each(function() {
var tr = $(this).find("tr");
tr.bind("mouseover", function() {
//var __originColor = $(this).find("td:first").css("border-color");//保存之前的color
$(this).find("td").css({"background-color": options.highlightColor});
if (options.affectBorder) { $(this).find("td").css("border-color", options.highlightColor); }
})
.bind("mouseout", function() {
//var __originColor = $(this).attr("__originColor");
$(this).find("td").css({"background-color": options.backgroundColor});
if (options.affectBorder) { $(this).find("td").css("border-color", options.originColor); }
});
if (options.hasHeader) { $(tr[0]).unbind("mouseover").unbind("mouseout"); }
if (options.hasTail) { $(tr[tr.length - 1]).unbind("mouseover").unbind("mouseout"); }
});
};
})(jQuery);