$.fn refers to the jquery namespace, plus the methods and properties on the FN, which are valid for each jquery instance.
such as extension $.fn.abc (), or $.FN.ABC () is an ABC method for jquery extension, then each of your jquery instances can refer to this method.
Then you can look like this: $ ("#div"). ABC ();
jquery has two methods for developing plug-ins, namely:
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.
Copy CodeThe code is as follows:
Jquery.fn = Jquery.prototype ={
Init:function (Selector, context) {//....
//......
};
The original Jquery.fn =jquery.prototype, prototype certainly not strange.
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) {returna+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:
jquery Code
$.fn.extend ({
Alertwhileclick:function () {
$ (this). Click (function () {
Alert (This). Val ());
});
}
}); From: http://www.jb51.net/article/42816.htm
jquery extension $.fn