asaworker
asked on
Expand Collapse left navigation ul tag using jQuery
I'm trying to find a jquery function or plugin that allows for a left navigation to enable expand/collapse using a plus/minus sign. The html will be aq bunch of unorderedlists. If you are oin a particular level and that page is displayed, the class becomes selected and each level has a different background color. Does anyone know how to implement this or see an example? I've searched the web for days and found some examples but none fit what I'm trying to do.
I prefer to use the 1.3.2 framework if possible.
I prefer to use the 1.3.2 framework if possible.
expand calls minus sign
selected updates bg color
<ul id="left-nav">
<li class="expand selected"><a href="">Test</a>
<ul><li>test 2</li></ul></li></ul>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hope the following code helps
************************** ********** ********** ********** ********** ********** ********** ****
<html>
<head>
<script type="text/javascript" language="javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function ()
{
$("#thirdpane li.menu_head").mouseover(f unction()
{
$(this).css({backgroundIma ge:"url(do wn.png)"}) .next("ul. menu_body" ).slideDow n(500).sib lings("ul. menu_body" ).slideUp( "slow");
});
});
</script>
<style type="text/css">
body {
margin: 10px auto;
font: 75%/120% Verdana,Arial, Helvetica, sans-serif;
}
.menu_list {
width: 150px;
list-style-type:none;
}
.menu_head {
padding: 5px 10px;
cursor: pointer;
position: relative;
margin:1px;
font-weight:bold;
background: #eef4d3 url(left.png) center right no-repeat;
}
.menu_body
{
display:none;
list-style-type:none;
}
.menu_body li a{
display:block;
color:#006699;
background-color:#EFEFEF;
padding-left:10px;
font-weight:bold;
text-decoration:none;
}
.menu_body li a:hover{
color: #000000;
text-decoration:underline;
}
</style>
</head>
<body>
<ul class="menu_list" id="thirdpane">
<li class="menu_head">Header-1 </li>
<ul class="menu_body">
<li><a href="#">Link-1</a></li>
<li> <a href="#">Link-2</a></li>
<li><a href="#">Link-3</a></li>
</ul>
<li class="menu_head">Header-2 </li>
<ul class="menu_body">
<li><a href="#">Link-1</a></li>
<li> <a href="#">Link-2</a></li>
<li><a href="#">Link-3</a></li>
</ul>
</ul>
</body>
</html>
**************************
<html>
<head>
<script type="text/javascript" language="javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function
{
$("#thirdpane li.menu_head").mouseover(f
{
$(this).css({backgroundIma
});
});
</script>
<style type="text/css">
body {
margin: 10px auto;
font: 75%/120% Verdana,Arial, Helvetica, sans-serif;
}
.menu_list {
width: 150px;
list-style-type:none;
}
.menu_head {
padding: 5px 10px;
cursor: pointer;
position: relative;
margin:1px;
font-weight:bold;
background: #eef4d3 url(left.png) center right no-repeat;
}
.menu_body
{
display:none;
list-style-type:none;
}
.menu_body li a{
display:block;
color:#006699;
background-color:#EFEFEF;
padding-left:10px;
font-weight:bold;
text-decoration:none;
}
.menu_body li a:hover{
color: #000000;
text-decoration:underline;
}
</style>
</head>
<body>
<ul class="menu_list" id="thirdpane">
<li class="menu_head">Header-1
<ul class="menu_body">
<li><a href="#">Link-1</a></li>
<li> <a href="#">Link-2</a></li>
<li><a href="#">Link-3</a></li>
</ul>
<li class="menu_head">Header-2
<ul class="menu_body">
<li><a href="#">Link-1</a></li>
<li> <a href="#">Link-2</a></li>
<li><a href="#">Link-3</a></li>
</ul>
</ul>
</body>
</html>
ASKER
This is exactly what I was looking for.
ASKER
Ran into a small problem.. what if each level has to be an actual link.. the expand/collapse won't work because the href gets triggered first. Any ideas?
then also it is possible just change the css and the html and it would work fine
ASKER
I tried that with no luck.. How would you prpose using the example given to do that?
Let me see if I can create one using jQuery!
Ref - https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/CSS/Q__24809365.html
Open in new window