//鼠标移上去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);

相关文章:

  • 2021-10-21
  • 2022-12-23
  • 2022-12-23
  • 2021-08-07
  • 2021-06-11
  • 2022-12-23
  • 2021-07-20
  • 2021-08-26
猜你喜欢
  • 2021-06-18
  • 2022-12-23
  • 2021-07-17
  • 2022-02-07
  • 2021-11-24
  • 2022-12-23
  • 2021-12-10
相关资源
相似解决方案