jQuery's $.extend(), $.fn and $.fn.extend()
jQuery provides two methods for developing plug-ins, namely:
jQuery.fn.extend();
jQuery.extend();
jQuery is a very well encapsulated class. For example, we use the statement $(“#btn1”) to generate an instance of the jQuery class.
jQuery.extend(object)
Adding a class method to the jQuery class can be understood as adding a static method.
$.extend({min: function(a,b){if(a<b) return a ;else return b;}});
$.min(1,2);
The extension of jQuery.prototype is to add "member functions" to the jQuery class. Instances of the jQuery class can use this "member function".
$.fn.extend({min: function(a,b){if(a<b)return a;return b;}});
$("#zs").min(1,2);