Write the tab sliding door by yourself based on jquery (General Edition)

Source: Internet
Author: User

Css: Copy codeThe Code is as follows:. main
{
Height: 360px;
Width: 290px;
Border: 1px solid #444444;
Font-size: 12px;
Color: #444444;
Margin: 20px;
}
. Main_top
{
Height: 30px;
Width: 290px;
Line-height: 30px;
Text-align: left;
Background-color: #999999;
Border-bottom: 1px solid #444444;
}
. Main_top ul
{
Padding: 0px;
Margin: 0px;
List-style-type: none;
Position: absolute;
}
. Main_top ul li. h_qian
{
Float: left;
Width: 80px;
Text-align: center;
Background-color: #999999;
Height: 30px;
}
. Main_top ul li. h_hou
{
Float: left;
Width: 80px;
Text-align: center;
Background-color: # ffffff;
Cursor: pointer;
Margin-top: 1px;
Height: 30px;
Font-weight: bold;
}
. Main_content
{
Margin: 10px;
}

Js:Copy codeThe Code is as follows: function tabchange (obj, p, c, q, h ){
$ (Obj). parent (). find ("li"). attr ("class", "" + q + "");
$ (Obj). parents ("." + p + ""). find ("." + c + ""). hide ();
$ (Obj). attr ("class", "" + h + "");
Var j = $ (obj). index ();
$ (Obj ). parents (". "+ p + ""). find (". "+ c +": eq ("+ j + ")"). show ();
}

Html:Copy codeThe Code is as follows: <div class = "main">
<Div class = "main_top">
<Ul>
<Li class = "h_hou" onmouseover = "tabchange (this, 'main', 'main _ content', 'H _ qian ', 'H _ hou ') "> Module 1 </li>
<Li class = "h_qian" onmouseover = "tabchange (this, 'main', 'main _ content', 'H _ qian ', 'H _ hou ') "> module 2 </li>
<Li class = "h_qian" onmouseover = "tabchange (this, 'main', 'main _ content', 'H _ qian ', 'H _ hou ') "> Module 3 </li>
</Ul>
</Div>
<Div class = "main_content"> 1st
</Div>
<Div class = "main_content" style = "display: none;"> 2nd
</Div>
<Div class = "main_content" style = "display: none;"> 3rd
</Div>
</Div>

The code is very simple and I will not talk about it much. For detailed usage instructions, see the annotations in tangtab. js in the Demo.

Appendix:
Online Demo: http://demo.jb51.net/js/2012/TabDemo/
Package and download: TabDemo_jb51.rar

Related Article

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.