$.fn refers to the jquery namespace, plus the methods and properties on the FN, which are valid for each jquery instance,
. Fn refers to the jquery namespace, plus the methods and properties on the FN, which are valid for each jquery instance.
such as extended $.FN.ABC ()
Then you can look like this: $ ("#div"). ABC ();
Usually use the Extend method extension, see the API in detail.
$.FX refers to the special effects of jquery.
If you use display, swipe, fade, animate, and so on.
$.fx.off can turn off the animation, in fact, the results are displayed directly.
extend and fn.extend of jquery
jquery has two methods for developing plug-ins, namely:
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); Adds a method to a jquery object.
What's the FN thing? If you look at 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 clear class concept, it is more convenient to use a class to understand it.
jquery is a well-encapsulated class, such as 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. Such as:
$.extend ({
Add:function (A, b) {return a+b;}
});
Adds a "static method" for jquery to add, which can then be used where jquery is introduced,
$.add (3,4); Return 7
JQuery.fn.extend (object); The extension to Jquery.prototype is to add "member functions" to the jquery class. An instance of the jquery class can use this "member function".
For example, we want to develop a plugin, make a special edit box, when it is clicked, then alert the contents of the current edit box. You can do this:
$.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 implements the extension, which pops up the contents of the current edit each time it is clicked.
The real development process, of course, do not make such a small white plug-in, in fact, jquery arch a wealth of operating documents, events, CSS, Ajax, effects of methods, combined with these methods, you can develop more niubility plug-ins.
jquery (function () {}) differs from (function () {} (jquery)
1.
JQuery (function () {});
All written as
JQuery (DOCUNEMT). Ready (function () {
});
The meaning is to execute the Ready () method after the DOM is loaded
2.
(Funtion () {
} (JQuery);
The actual execute () (para) anonymous method simply passes the jquery object.
Summary: JQuery (Funtion () {}); The code used to hold the DOM object, the DOM object already exists when executing code. cannot be used to store development plug-in code. Because the jquery object is not being passed, the external call does not come through the Jquery.methodye method.
(Funtion () {
} (JQuery);
Used to store the code that develops the plug-in, where the code DOM does not necessarily exist, directly executes the DOM operation code with care
What does jquery $.fn $.fx mean?