Accordion folding menu Based on jquery

Source: Internet
Author: User

Initialize to all hidden

Point one, show the first hidden content

When the point is second, the first content is hidden, the contents of the second column are displayed, and so on

Here is the Code section

<! DOCTYPE html>
<meta charset= "UTF-8" >
<title>Title</title>
<style>
* {
margin:0;
padding:0;
}

Body {
font:14px/22px "Microsoft Yahei", Arial, serif;
}

A, a:link, a:visited {
Color: #ccc;
Text-decoration:none;
}

. Content {
margin:50px Auto;
width:220px;
Height:auto;
}

. Content > UL {
List-style:none;
}

. content. menu-one > Li {
width:220px;
Height:auto;
Overflow:hidden;
border-top:1px solid #888;
}

. Content. menu-one > Li.firstchild {
border:0;
}

. content. Menu-one. Header {
height:35px;
Background: #666;
line-height:34px;
text-indent:15px;
Cursor:pointer;
}

. Content. Menu-one. header:hover,. Content. Menu-one. menuone-current {
Background: #777;
}

. content. Menu-one. Header > Span {
Display:block;
}

. content. menu-one header. txt {
Float:left;
Color: #fff;
}

. content. menu-one header. Arrow {
Float:right;
width:35px;
height:35px;
Background:url (arrow-d.png) No-repeat Center Center;
}

. Content. menu-two {
Display:none;
width:220px;
Height:auto;
}

. content. menu-two Li {
width:220px;
height:35px;
Background: #eee;
border-top:1px solid #ccc;
line-height:34px;
text-indent:40px;
}

. Content. menu-two Li.firstchild {
border:0;
}

. content. Menu-two Li a {
Display:block;
Color: #888;
}

. Content. menu-two li:hover,. Content. menu-two Li.menutwo-current {
Background: #fff;
}

. content. menu-show. Header {
Background: #777;
}

. content. menu-show header. Arrow {
Background-image:url (arrow-u.png);
}
</style>
<script src= "Js/jquery-1.11.0.min.js" type= "Text/javascript" ></script>

<body>

<div class= "Content" >
<ul class= "Menu-one" >
<li class= "FirstChild" >
<div class= "header" ><span class= "TXT" > HTML5 basic Tutorials </span> <span class= "Arrow" ></span> </div>
<ul class= "Menu-two" >
<li class= "FirstChild" ><a href= "#" &GT;HTML5 Basic tutorial 01</a></li>
<li><a href= "#" &GT;HTML5 Basic tutorial 02</a></li>
<li><a href= "#" &GT;HTML5 Basic tutorial 03</a></li>
<li><a href= "#" &GT;HTML5 Basic tutorial 04</a></li>
</ul>
</li>
<li>
<div class= "header" ><span class= "txt" > II, CSS3 Basic tutorials </span> <span class= "Arrow" ></span> </div>
<ul class= "Menu-two" >
<li class= "FirstChild" ><a href= "#" &GT;CSS3 Basic tutorial 01</a></li>
<li><a href= "#" &GT;CSS3 Basic tutorial 02</a></li>
<li><a href= "#" &GT;CSS3 Basic tutorial 03</a></li>
<li><a href= "#" &GT;CSS3 Basic tutorial 04</a></li>
</ul>
</li>
<li>
<div class= "header" ><span class= "txt" > Third, JavaScript Basic tutorial </span> <span class= "Arrow" ></ Span></div>
<ul class= "Menu-two" >
<li class= "FirstChild" ><a href= "#" >javascript Basic tutorial 01</a></li>
<li><a href= "#" >javascript Basic tutorial 02</a></li>
<li><a href= "#" >javascript Basic tutorial 03</a></li>
<li><a href= "#" >javascript Basic tutorial 04</a></li>
</ul>
</li>
<li>
<div class= "header" ><span class= "txt" > PHP basic Tutorials </span> <span class= "Arrow" ></span> </div>
<ul class= "Menu-two" >
<li class= "FirstChild" ><a href= "#" >php Basic tutorial 01</a></li>
<li><a href= "#" >php Basic tutorial 02</a></li>
<li><a href= "#" >php Basic tutorial 03</a></li>
<li><a href= "#" >php Basic tutorial 04</a></li>
</ul>
</li>
<li>
<div class= "header" ><span class= "txt" > V, basic iOS tutorial </span> <span class= "Arrow" ></span> </div>
<ul class= "Menu-two" >
<li class= "FirstChild" ><a href= "#" >ios Basic tutorial 01</a></li>
<li><a href= "#" >ios Basic tutorial 02</a></li>
<li><a href= "#" >ios Basic tutorial 03</a></li>
<li><a href= "#" >ios Basic tutorial 04</a></li>
</ul>
</li>
</ul>
</div>


<script>
$ (document). Ready (function () {
var Amenuoneli = $ (". Menu-one > Li");
var amenutwo = $ (". Menu-two");

$ (". Menu-one > Li >. Header"). each (function (i) {
$ (this). Click (function () {
if ($ (amenutwo[i)). CSS ("display") = = "Block") {
$ (Amenutwo[i]). Slideup (300);
$ (Amenuoneli[i]). Removeclass ("Menu-show")
}else{
for (var j = 0; J < Amenutwo.length; J + +) {
$ (Amenutwo[j]). Slideup (300);
$ (Amenuoneli[j]). Removeclass ("Menu-show");
}
$ (Amenutwo[i]). Slidedown (300);
$ (Amenuoneli[i]). addclass ("Menu-show")
}
});
});
});
</script>
</body>

The second method (PS: Compared to the first one is relatively simple, but also can be used)

<ul>
<li class= "" >
<a href= "javascript:;" >
<span> My profile </span>
</a>
<ul>
<li>
<a href= "wodeziliao.html" >
<span> My Profile </span>
</a>
</li>
</ul>
</li>
<li class= "" >
<a href= "javascript:;" >
<span> my release </span>
</a>
<ul>
<li><a href= "wodefabu.html" ><span> my release </span></a></li>
<li><a href= "wodefabu.html" ><span> my release </span></a></li>
<li><a href= "wodefabu.html" ><span> my release </span></a></li>
<li><a href= "wodefabu.html" ><span> my release </span></a></li>
</ul>
</li>
<li class= "" >
<a href= "javascript:;" >
<span> My favorites </span>
</a>
<ul>
<li><a href= "wodeshoucang.html" ><span> My favorites </span></a></li>
<li><a href= "wodeshoucang.html" ><span> My favorites </span></a></li>
<li><a href= "wodeshoucang.html" ><span> My favorites </span></a></li>
<li><a href= "wodeshoucang.html" ><span> My favorites </span></a></li>
</ul>
</li>
<li class= "" >
<a href= "javascript:;" >
<span> my appointment </span>
</a>
<ul>
<li><a href= "" ><span> My appointment </span></a></li>
<li><a href= "" ><span> My appointment </span></a></li>
<li><a href= "" ><span> My appointment </span></a></li>
<li><a href= "" ><span> My appointment </span></a></li>
</ul>
</li>
<li class= "" >
<a href= "javascript:;" >
<span> My orders </span>
</a>
<ul>
<li><a href= "" ><span> My Orders </span></a></li>
<li><a href= "" ><span> My Orders </span></a></li>
<li><a href= "" ><span> My Orders </span></a></li>
<li><a href= "" ><span> My Orders </span></a></li>
</ul>
</li>
<li class= "" >
<a href= "xiugaimima.html" >
<span> Change Password </span>
</a>
</li>
<li class= "" >
<a href= "" >
<span> exit account </span>
</a>
</li>
</ul>

$(". Ep_my_data li "). Click (function () {
$ (this). Toggleclass ("ssDE");
$ (this). Children (". Ep_my_data Li ul "). Slidetoggle (" slow ");
});

Accordion folding menu Based on jquery

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.