美文网首页
jQuery插件

jQuery插件

作者: Seagull_papa | 来源:发表于2017-08-26 10:45 被阅读0次

1.jQuery插件分类

  • 封装对象方法的插件

应用最广

  • 封装全局函数的插件

作为jQuery全局函数插件

  • 选择器插件

作为jQuery选择器的补充

2.jQuery插件编写方法

封装对象方法的插件

(function($){
    $.fn.extend({                          //注意此处是fn
        "pluginName":function(arguments){
            //plugin code goes here.
        },
        "anotherPluginName":...
    });
})(jQuery);

插件写好后方可调用

封装全局函数的插件

(function($){
    $.extend({                          
        "pluginName":function(arguments){
            //plugin code goes here.
        },
        "anotherPluginName":...
    });
})(jQuery);

选择器插件

同封装全局函数的插件写法

3.获取网上的jQuery插件

网址:http://plugins.jquery.com
使用方法:参考插件api

相关文章

网友评论

      本文标题:jQuery插件

      本文链接:https://www.haomeiwen.com/subject/kuemdxtx.html