Have to write an article of their own, has been the future memory!
First post the plugin code, inside the comment
Copy Code code as follows:
(function ($) {
Extended
$.fn.extend ({
Plug-in name
Height:function (options) {
Default parameters
var defaults = {
Color: ' Red '
};
overriding 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);
Note the following (JQuery) must be the case, Q must be capitalized, J can not capitalize, or error.
The following is the use of code
Copy Code code as follows:
@{
Viewbag.title = "Home Page";
}
@section header{
<script src= "@Url. Content (" ~/scripts/jquery.extends.js ")" Type= "Text/javascript" ></script>
<script type= "Text/javascript" >
$ (function () {
$ ("P"). Height ({color: ' black '});
});
</script>
}
<p>
To learn more about ASP.net mvc visit <a href= "Http://asp.net/mvc" title= "asp.net mvc Website" >http://asp.net/mvc&l T;/a>.
</p>
Very simple, in fact, the development of jquery Plug-ins There are other methods, I just feel that this method is better, the readability is also better.
The jquery plugin is written here!