Tabs created in jquery + CSS

Source: Internet
Author: User

Now look at the sharp jquery... the benefit is not too small... the following... is a class note... the students who need it can handle the emergency ....

CSS Section

<Style type = "text/CSS">
. Hide {display: none ;}
Ul {list-style: none ;}
Li {width: 120px; float: Left ;}
. Tab_box Div {border: 1px solid # a0a0a4; width: 500px;/* Text-align: ecnter; */height: 100px; line-Height: 100px ;}
. Tab_menu {width: 500px; Height: 20px ;}
. Tab_box {margin: 1px 0 0 0 ;}
. Selected {padding: 2px 2px 0 2px; Background-color: #808080; border-bottom: 1px solid #808080 ;}

/* Border-bottom: 1px solid #808080 --- this is very important. compatible with ff and ie8...... if this FF is not added, there will be 1px blank ...*/
</Style>

Div

<Div class = "tab">
<Div class = "tab_menu">
<Ul>
<Li class = "selected"> current events </LI>
<Li> sports </LI>
<Li> entertainment </LI>
</Ul>
</Div>
<Div class = "tab_box">
<Div> current events </div>
<Div class = "hide"> sports </div>
<Div class = "hide"> entertainment </div>
</Div>
</Div>

Jquery Section

$ (function () {
var $ div_li = $ ("Div. tab_menu ul li ");
var $ Div =$ (" Div. tab_box> Div ");
$ div_li.click (function () {
$ (this ). addclass ("selected "). siblings (). removeclass ("selected");
var Index = $ div_li.index (this);
$ Div. eq (index ). show (). siblings (). hide ();
});

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.