Home > Web Front-end > JS Tutorial > Jquery plug-in development notes compilation_jquery

Jquery plug-in development notes compilation_jquery

WBOY
Release: 2016-05-16 18:11:58
Original
947 people have browsed it

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

Copy the code The code is as follows:

( 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
Copy the code The code is as follows:

@{
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!
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template