1, jquery plug-in type:
1), the plug-in that encapsulates the object method (equivalent to an instance method) (using $.fn.extend ({"Method name": function (parameter) {//Method body}}))
2), the plug-in that encapsulates the global function (equivalent to $ static method)
3), selector plug-in
2, the attention point
1), plug-in file naming specification: jquery. [Plugin name].js
2), object method attached to the Jquery.fn object on a static method attached to the JQuery object itself
3), inside the plug-in, this refers to the jquery object that the selector gets, not the DOM object
4), can traverse all elements through This.each ()
5), plug-ins should return a jquery object to ensure chained programming unless the plug-in needs to return some specific values
Custom instance plug-ins
$.fn.extend ({
"Color": function (value) {
if (value==undefined) {return this.css ("Color");}
Else
{
return this.css ("Color", value);
}
}
});
Customizing the global method plug-in
$.extend ({"SayHello": function (v) {
Alert ("Hello,my Name is" +v);
}});
Another common use of $.extend is to merge other objects onto the target object. The first parameter True indicates a deep copy
$.extend (True, target object, Object1);
How jquery customizes plugins (extended instances/static methods)