jquery表格简单插件

1、一直对jquery插件感觉非常神奇。今天动手写了一个超级简单的案例。

2、效果

3、体会

a、jquery插件编写能力。

须要具备一定js能力的编写。还有写css样式的运用;希望以后这方面会有提高。

b、能封装插件尽量封装。

c、面向对象的方式去写对象。

4、代码

/**
 * Created by Administrator on 2015/8/17 0017.
 */
(function ($) {
    $.fn.tableUI = function (options) {
        var defalus = {
            evenRowClass: "evenRow",
            oddClass: "oddRow",
            activeRowClass: "activeRow"
        }
        var options = $.extend(defalus, options);
        // do somethings
        this.each(function () {
            var thisTable = $(this);
            //加入奇偶行颜色
            $(thisTable).find("tr:even").addClass(options.evenRowClass);
            $(thisTable).find("tr:odd").addClass(options.oddClass);
            //加入活动行颜色
            $(thisTable).find("tr").bind("mouseover", function () {
                $(this).addClass(options.activeRowClass);
            });
            $(thisTable).find("tr").bind("mouseout", function () {
                $(this).removeClass(options.activeRowClass);
            });
        });
    }
})(jQuery);

5、源码

http://download.csdn.net/detail/u011431550/9016657

posted on 2017-06-09 12:56  yjbjingcha  阅读(101)  评论(0编辑  收藏  举报

导航