Class-level plug-in development, which is primarily defined as a global method in jquery://The first way of writing jquery.myfunc = function (str) { alert ("define method directly in jquery", str)}//call mode $. MyFunc ("hello!"); /second notation Jquery.extend ({ myfunc:function (str) { alert ("Extend extension $ method", str) }})//Call Way $.myfunc (" Hello! "); /third: In order to not pollute the global, mount an object as a namespace, all the custom methods are put here to ensure that jquery is globally secure. jquery.define={ myfunc:function (str) { alert ("notation for Namespaces", str) }}//called: $.define.myfunc ("Hello");// The above three kinds is the level plug-in development way, is not commonly used, from the invocation way to see, they are the global execution, does not need to bind the node object. Object level plug-in development: there is a canonical template; (function ($) { $.fn.plugin = function (options) { var defaults = { //various default parameters } var options = $.extend (defaults,options);//The passed parameter overrides the default parameter This.each (function () { var _this = $ (this); Cache the node objects that the plugin passes in. //execute Content }) return $ (this); Returns the Node object in order to support chained calls. }}) (jQuery);//Call Way $ ("selector"). Plugin ({ //custom parameters, JSON format})
Https://www.cnblogs.com/chengyunshen/p/7277305.html
jquery Plugin jquery Plugin development