Jquerytab plugin implementation code _ jquery

Source: Internet
Author: User
Jquery plug-ins are rich and many of them are very useful. I recently learned how to create jquery plug-ins and found that jquery plug-ins are actually very simple. Here I will introduce them. Basic Format of jquery plug-in:

The Code is as follows:


(Function ($ ){
$. Fn. tab = function (options) {// The tab next to $. fn is the function name of this plug-in. You can make changes as you like.
Var defaults = {
// Related property settings
}
Var options = $. extend (defaults, options );
This. each (function (){
// Implemented function settings });
};
}) (JQuery );


Here is a tab plug-in for me to complete the above Code

The Code is as follows:


(Function ($ ){
$. Fn. tab = function (options ){
Var defaults = {
Eventname: "click", // trigger event, click as click, and mousemove as mouse
Titlekeyid: "tabtitle", // switch ID
Sedcss: "sed", // CSS when selected
Nosedcss: "nosed" // CSS when not selected
}
Var options = $. extend (defaults, options );
This. each (function (){
Var tab = $ (this );
// Bind events
$ (Tab). find ("li"). bind (options. eventname, function (){
$ ("#" + Options. titlekeyid). find ("li"). attr ("class", options. nosedcss );
$ (This). attr ("class", options. sedcss );
$ ("#" + Options. titlekeyid + "info"). find ("p" ).css ("display", "none ");
$ ("#" + $ (This). attr ("id") + "info" ).css ("display", "block ");
// Individual JS capabilities are still limited, and the code is not well written.
});
});
};
}) (JQuery );


I think you have used some jquery plug-ins. Here I will look at the code used by the plug-ins:
(Code 2)

The Code is as follows:


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.