I. Method list:
1. jQuery. extend (Object); // jQuery Extension Method
2. jQuery. fn. extent (Object); // jQuery selected Object Extension Method
Ii. Call example:
1. An example of jQuery extension method is as follows:
Copy codeThe Code is as follows: jQuery. extend ({
Meg: function (message ){
Alert (message );
},
MegToo: function (messageToo ){
Alert (messageToo );
}
});
Page call: jQuery. Meg ("Hi, Stone ");
Meg and MegToo are my jQuery custom extension methods. Multiple extension methods are separated by commas.
2. There are two writing methods for the extended object selected by jQuery.
A) Example of jQuery's object extension method is as follows:Copy codeThe Code is as follows: jQuery. fn. extend ({
ShowHtml: function (showhtml ){
JQuery(this).html (showhtml );
}
});
Page call: jQuery ("# htmlDiv"). ShowHtml ("Stone, Hi! ");
ShowHtml is the extension method for the objects selected by jQuery. Multiple extension methods are separated by commas.
B) Example 2 of jQuery's object extension method is as follows:Copy codeThe Code is as follows: (function (jq ){
Jq. fn. ShowHtmlToo = function (showhtml ){
JQuery(this).html (showhtml );
};
}) (JQuery)
Same call Method 1: jQuery ("# htmlDiv"). ShowHtmlToo ("Stone, Hi! ");
Stone preparation]