1. Method list:
1.jQuery.extend(Object); // jQuery’s own extension method
2.jQuery.fn.extent(Object); // jQuery selected object extension method
2 , Calling example:
1. The extension method example of jQuery itself is as follows:
jQuery.extend({
Meg: function (message) {
alert(message);
},
MegToo: function (messageToo) {
alert(messageToo) ;
}
});
Page call: jQuery.Meg("Hi,Stone");
Where Meg and MegToo are my jQuery custom extension methods, Multiple extension methods are separated by commas.
2. There are two ways to write the jQuery selected object extension method.
a) The jQuery selected object extension method example is as follows:
jQuery.fn.extend({
ShowHtml: function (showhtml) {
jQuery(this).html(showhtml);
}
});
Page call: jQuery("#htmlDiv").ShowHtml("Stone, Hi!");
Where ShowHtml is the extension method of my jQuery selected object, and multiple extension methods are separated by English commas .
b) The jQuery selected object extension method instance 2 code is as follows:
(function (jq) {
jq.fn.ShowHtmlToo = function (showhtml) {
jQuery(this).html(showhtml);
};
})(jQuery)
The call is the same as method 1: jQuery("#htmlDiv").ShowHtmlToo("Stone, Hi!");
【Stone production and organization】