• 自制的几个jquery插件


    1.颜色插件,比用css方便些

    //1.插件编写
            ;(function ($) {
                $.fn.extend({
                    "color":function(value){
                       return this.css("color",value);
                    }
                });
            })(jQuery);
    
     //2.插件应用
            $(function () {
                $("div:eq(1)").color("red");
            });

    1.表格各行变色插件

    //1.插件编写
    
           ;(function ($) {
                $.fn.extend({
                    "alterBgColor":function(options){
                        options = $.extend({
                            odd:"odd",
                            even:"even",
                            selected:"selected"
                        },options);
                        this.each(function(){
                            $("tbody>tr:odd", this).addClass(options.odd);
                            $("tbody>tr:even", this).addClass(options.even);
                            $("tbody>tr",this).click(function(){
                                var hasSelected = $(this).hasClass(options.selected);
                                $(this)[hasSelected ? "removeClass":"addClass"](options.selected).find(":checkbox").attr("checked",!hasSelected);
                            });
                        });
                    }
                });
            })(jQuery);
            //2.插件应用
            $(function () {
                $("table").alterBgColor();
            });
    

      

  • 相关阅读:
    牛客网每日一练
    牛客网每日一练
    牛客网每日一练
    linux解压命令 迎客
    japid 研究 迎客
    Linux 下载工具 wget 迎客
    Nginx 安装 迎客
    Redmine 迎客
    安装 Redis 迎客
    http状态码一览表 迎客
  • 原文地址:https://www.cnblogs.com/stevenjson/p/3334515.html
Copyright © 2020-2023  润新知