jquery Simple Implementation page Option Carter effect _jquery

Source: Internet
Author: User

Css:

Copy Code code as follows:

. clear{clear:both; height:0px; overflow:hidden;}
. tab{width:400px; font-size:12px;}
. Tab_menu ul{padding:0px;margin:0px;}
. tab_menu Li{list-style:none; display:block; float:left;
Background: #C2CEFE; height:22px; line-height:22px;
padding:0px 8px; margin-right:6px; border: #86B4CA 1px solid;
}
box{width:400px height:200px; Overflow:hidden border: #A8C9D9 1px solid; padding:10px 8px;}
. Tab_menu ul Li.selected{background: #dadada; cursor:pointer;}
. Hide{display:none;}

Jquery:

Copy Code code as follows:

$ (function () {
var $menu _li = $ ("Div.tab_menu ul Li"); Select Web Page tab
$menu _li.click (function () {
$ (this). AddClass ("selected")//Current <li> Highlight
. siblings (). Removeclass ("selected"); Get rid of other peers <li> highlights
var index = $menu _li.index ($ (this)); Index of <li> child nodes found
$ ("Div.tab_box > div"). EQ (index). Show ()///index n DIV display
. siblings (). Hide (); Other tabs are hidden
})
})

Html:

Copy Code code as follows:

<div class= "tab" >
<div class= "Tab_menu" >
<ul>
<li class= "Selected" > Personal information </li>
<li class= "selected" > My photos </li>
<li class= "selected" > My blog </li>
<div class= "Clear" ></div>
</ul>
</div>
<div class= "Tab_box" >
<div class= "box" > My qq:123456</div>
<div class= "box Hide" >hi </div>
<div class= "box hide" > Hello <br> </div>
</div>
</div>

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.