(function ($) {
$.fn.extable = function (options) {
var $default = { evenStyle: "evenstyle", oddStyle: "oddstyle", activeStyle: "activestyle" };
var opts = $.extend({}, $.fn.extend(), $default);
$(this).find("tr:even").addClass(opts.evenStyle);
$(this).find("tr:odd").addClass(opts.oddStyle);
$(this).find("tr").mouseenter(function () {
$(this).addClass(opts.activeStyle);
});
$(this).find("tr").mouseleave(function () {
$(this).removeClass(opts.activeStyle);
});
};
})(jQuery);
使用:
偶数行样式:evenstyle{background-color:#fff;}
奇数行样式:oddStyle{background-color:green;}
鼠标滑过样式:activestyle{background-color:red;}
$("#table").extable();