JQuery隔行变色

(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();

posted @ 2012-11-06 10:46  吕川福  阅读(163)  评论(0编辑  收藏  举报