I have no choice but to write an article myself so that I can remember it later!
First post the plug-in code with comments
( function ($) {
//Extend
$.fn.extend({
//Plug-in name
height: function (options) {
//Default parameters
var defaults = {
color: 'red'
};
//Override the default parameters
var opts = $.extend(defaults, options);
//Main function
return this .each(function () {
//Activate event
var obj = $(this);
obj.click(function () {
alert(opts.color);
} );
});
}
})
})(jQuery);
//The following (jQuery) must be like this, Q must be capitalized, j cannot be capitalized, Otherwise, something goes wrong.
The following is the usage code
@{
ViewBag.Title = "Home Page";
}
@section Header{
}
@ViewBag.Message
< p>
To learn more about ASP.NET MVC visit
http://asp.net/mvc< ;/a>.
It’s very simple. In fact, there are other ways to develop Jquery plug-ins. I just feel that this method is better and more readable. good.
Jquery plug-in is written here!
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