jQuery.fn.extend(object); Expand jQuery.prototype , which is to add "member functions" to the jQuery class. Instances of the jQuery class can use this "member function".
For example, we want to develop a plug-in to create a special edit box. When it is clicked, the content in the current edit box will be alerted. You can do this: JavaScript code
$(“#input1″) is a jQuery instance. When it calls the member method alertWhileClick, it implements expansion. Each time it is called When clicked, it will first pop up the content currently being edited.
In the real development process, of course you will not make such a novice plug-in. In fact, jQuery provides a wealth of methods for operating documents, events, CSS, Ajax, and effects. Combining these methods, you can develop Publish more Niubility plug-ins.
Note:
There is another special place here, that is, jQuery.extend = jQuery.fn.extend at the beginning of the function, and in the program jQuery.prototype has been assigned to jQuery.fn earlier, so different calls to jQuery.extend() and jQuery.fn.extend() will appear in subsequent calls. The results of these two method calls are also different. The call of jQuery.extend() does not extend the method to the instance of the object. The method that refers to it also needs to be implemented through the jQuery class, such as jQuery.init(), and the call of jQuery.fn.extend() extends the method Extended to the prototype of the object, so when a jQuery object is instantiated, it has these methods, which is very important, and this is reflected everywhere in jQuery.js
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn