I. Extension of the jquery class method
/**
* Extended jquery class method (equivalent to class static method $.methodname (param))
*/
$.extend ({con:function (value) {Console.log (value)})//class method call $.con (' The author is a package Jian author is a package Jian author is a package Jian author is a package Jian author is a package Jian author is a package Jian ');
Ii. extending the JQuery object approach
/**
* Extend the JQuery object method (equivalent to the static method of the class $ (' #id '). MethodName (param))
* by id/class/tag name gets the object, direct $. Method name is the class (in the hypothetical sense of the class)
* Jquery.fn = Jquery.prototype = {//This is the instantiation of a JQuery object
*init:function (Selector, context) {//....
*//......
* };
*/
});///The second class defines the JQuery method (defining a single method), the two classes are actually the same principle, divided into two types is also my own set, wrong do not spray $.fn.myplugin = function (options) {$options = $.extend ({htm L: "No Messages", CSS: {"color": "Red", "font-size": "14px"}},options); return $ (this). CSS ($options. css). HTML ($options. html); }//Call $ ('. Ye '). Myplugin ({html: "So easy,yes?", css:{"color": "Green", "font-size": "50px"}); Label on page <span class= '. Ye ' ><span>
jquery Extend extension methods (class methods and Object methods)