(1) How to develop plug-ins:
Jquery.extend (object) is the extension of the jquery class itself, adding new methods to the class.
JQuery.fn.extend (object) Adds a method to a jquery object and adds a member function (Jquery.fn = jquery.prototype) to the jquery class.
(2) Specific wording: an extension of the notation is to call $.ab= ({}) when $.ab.add ()
$.extend ({
Sub:function (A, b) {returna-b;}
Add:function (A, b) {returna+b;}
});
$.fn.extend ({
Sub:function (A, b) {returna-b;}
Add:function (A, b) {returna+b;}
});
$.add (2,5);
(3) $.extend can also be used to merge objects:
Obj1 = {name: "John", Location: {City: "Boston"}};
Obj2 = {Last: ' Resig ', location: {state: ' MA '}};
Jquery.extend (True,obj1, obj2);
Results:
{name: ' John ', Last: ' Resig ', location: ' {state: ' MA '}}
True indicates a deep copy, changing the value of the OBJ2 does not affect the value of obj1, and if a shallow copy is made, changing the object value in the OBJ2 causes the object value in the Obj1 to change.
Jquery---$.fn---jQuery.fn.extend