Use the extension functions provided by the JQuery library to implement custom methods and jquery extension Functions
The JQuery package provides a large number of methods that can be directly used on the page. However, none of the libraries can meet all requirements. Therefore, the JQuery Library provides a wide range of extension functions. Take disabling a group of form elements as an example to see how to simply and effectively add custom function extensions to the JQuery library. (JQuery has no way to disable form elements)
Code:
<! DOCTYPE>
The text box and button have been disabled:
If you only disable the button, add a css class;
jQuery(function() {$("form input.test").disable(); });
Check whether the button is disabled:
Implementation is also very simple, open the jquery-2.1.1.js source code, no compression, relatively easy, I introduced
And then add the following code
jQuery.fn.disable=function () { return this.each(function() { if(this.disabled != null) this.disabled=true; }); }
You can use the method described above.
In the book JQuery In Action, I mentioned the extension (P12) using the $. fn. method name method. I tested it and didn't disable it. The error is still correct.
Custom JQuery Extension Method
You later wrote the "showLbtDialog" function, so the call method is $ ("# div"). showLbtDialog ();
To call the original extension, the call method is $. lbtDialog. lbtSetDiv.
You see
JQuery. fn. extend ({
ShowLbtDialog: function (p ){
Var lbt = $. extend (true, {}, $. lbtDialog, p );
Return lbt. lbtSetDiv;
}
In this section, the method has already been called.
How does JQUERY call udfs?
Custom ?? It depends on how you define the method. It can be used directly, for example, function aa () {}, which is directly aa (), if it is a custom method extended to the jQuery object, there are two kinds of usage, one is $. extend ({'aa': function () {}}), which is like this $. aa (), another type such as $. fn. extend ({'aa': function () {}}). this is the case for calling $ (this ). aa ()