Jquery Plugin Development Notes Collation _jquery

Source: Internet
Author: User
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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.