$.fn refers to the jquery namespace, plus the methods and properties on FN, which are valid for each of the jquery instances.
such as extended $.FN.ABC ()
Then you can look like this: $ ("#div"). ABC ();
Usually use the Extend method to expand, see the API in detail.
$.fx refers to jquery's special effects.
If you use display, slide, fade, animation, and so on.
$.fx.off can turn off animations, which actually display the results directly.
jquery's Extend and fn.extend
jquery has two methods for developing Plug-ins, respectively:
JQuery.fn.extend (object);
Jquery.extend (object);
Jquery.extend (object); To extend the jquery class itself. Adds a new method to the class.
JQuery.fn.extend (object); Add methods to the JQuery object.
What is FN? See the jquery code, it's not hard to find.
Jquery.fn = Jquery.prototype = {
Init:function (Selector, context) {//....
//......
};
The original Jquery.fn = Jquery.prototype. It's certainly not strange to prototype.
Although JavaScript does not have a well-defined class concept, it is more convenient to use classes to understand it.
jquery is a very nicely encapsulated class, for example, we use statement $ ("#btn1") to generate an instance of a jquery class.
Jquery.extend (object); Adding a class method to the jquery class can be understood as adding a static method. Such as:
$.extend ({
Add:function (a,b) {return a+b;}
});
Add a "static method" for jquery, and then you can use this method in the place where jquery is introduced,
$.add (3,4); Return 7
JQuery.fn.extend (object); The extension to Jquery.prototype is to add a "member function" to the jquery class. Examples of jquery classes can use this "member function".
For example, we want to develop a plugin, make a special edit box, when it is clicked, alert the contents of the current edit box. Can do this:
jquery Code:
Copy Code code as follows:
$.fn.extend ({
Alertwhileclick:function () {
$ (this). Click (function () {
Alert ($ (this). Val ());
});
}
});
$ ("#input1"). Alertwhileclick ();
On the page: <input id= "INPUT1" type= "text"/>
$ ("#input1") is a jquery instance, and when it calls the Member method Alertwhileclick, it expands, which pops up the contents of the current editor each time it is clicked.
The real development process, of course, will not do so small white plug-ins, in fact, jquery arch the rich operation of the document, events, CSS, Ajax, the effect of the method, combined with these methods, you can develop a more niubility plug-ins.
jquery (function () {}) differs from (function () {} (jquery)
1.
JQuery (function () {});
All written as
JQuery (DOCUNEMT). Ready (function () {
});
Meaning to execute the ready () method after the DOM has finished loading
2.
(Funtion () {
} (JQuery);
The actual execute () (para) anonymous method simply passes the jquery object.
Summary: JQuery (Funtion () {}); code that holds the DOM object, and the DOM object already exists when the code executes. cannot be used to store development plug-in code. Because the jquery object is not passed, the external jquery.methodye call does not come with the method.
(Funtion () {
} (JQuery);
The code used to store the development plug-in, executing the code DOM does not necessarily exist, automate the DOM manipulation code, and use it carefully.