Let's get down to the truth and start your study :);
1. jquery customizes jQuery. extend () and jQuery. fn. extend () method, where jQuery. the extend () method can create global functions or selectors, whereas jQuery. fn. extend () can create jQuery object methods. These two methods all contain a parameter. to modify the parameter, only the object of the name/value pair structure is accepted. The name indicates the function or method name, the value indicates the function body.
Copy codeThe Code is as follows:
JQuery. extend ({
MinValue: function (a, B ){
Return a> B? B:;
},
MaxValue: function (a, B ){
Return a <B? B:;
},
})
Copy codeThe Code is as follows:
<Script>
$ (Function (){
$ ('Input'). click (function (){
Var a = prompt ("enter a value ");
Var B = prompt ("enter a value ");
Var c = jQuery. minValue (a, B );
Var d = jQuery. maxValue (a, B );
Alert ("minimum value you entered:" + c + "\ n the maximum value you entered:" + d );
});
});
<Script>
<Input type = "button" value = "jQuery plugin test"/>
In actual development, the jQuery. extend () method transmits parameters of the series option structure for the plug-in method.
Copy codeThe Code is as follows:
Function fn (options ){
Var options = jQuery. extend ({name1: value1, name2: value2, name3: value3}, options );
// Function body
}
Call:
Fn ({name1: value2, name2: jine, name3: hx}); // overwrite the new value
Fn ({name4: value2, name5: jine,}); // Add a new option
Fn (); // retain the default value
To be continued.