I've got this menu I'm working on...
Initially, "level-2" would appear below "level-1". I've been able to make move it to a 2nd column always sticking to the top. As far as I can see it's working!
The issue I've run into is adding more columns as I need at least another level, possibly two.
I think I’ve handled the HTML part (see Item 2 - Item 2-1 - Item 2-1-1), the issue now is the script. I tried replicating the current one, but just couldn't make it work...
Any help would be highly appreciated. Thanks
HTML:
<div class="wrapper">
<ul>
<li class="level-1"><a href="#">Item 1</a>
<ul class="level-2">
<li><a href="#">Item 1-1</a></li>
<li><a href="#">Item 1-2</a></li>
</ul>
</li>
<li class="level-1"><a href="#">Item 2</a>
<ul class="level-2">
<li><a href="#">Item 2-1</a>
<ul class="level-3">
<li><a href="#">Item 2-1-1</a></li>
</ul>
</li>
</ul>
</li>
<li class="level-1"><a href="#">Item 3</a>
<ul class="level-2">
<li><a href="#">Item 3-1</a></li>
<li><a href="#">Item 3-2</a></li>
<li><a href="#">Item 3-3</a></li>
</ul>
</li>
<li class="level-1"><a href="#">Item 4</a>
<ul class="level-2">
<li><a href="#">Item 4-1</a></li>
<li><a href="#">Item 4-2</a></li>
</ul>
</li>
</ul>
</div>
JS:
$('.level-2').hide();
$('.level-1').on('click', function(){
if(!($(this).children('.level-2').is(':visible'))){
$('.level-2').slideUp();
$(this).children('.level-2').slideDown();
} else {
$('.level-2').slideUp();
}
});
$('.level-2').on('click', function(e){
e.stopPropagation();
});
CSS:
body{
margin: 0px;
border: 0;
overflow: hidden;
}
ul {
list-style: none;
margin: 0;
padding: 0;
color: #000000;
}
ul li {
position: relative;
}
li ul {
position: absolute;
left: 120px;
top: 0;
display: none;
}
ul li a {
text-decoration: none;
color: #000000;
}
.level-1 {
position: relative;
top: 20px;
left: 20px;
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: normal;
line-height: 15px;
letter-spacing: 0em;
text-transform: uppercase;
}
.level-2 {
position: fixed;
top: 20px;
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: normal;
line-height: 15px;
letter-spacing: 0em;
text-transform: uppercase;
}
.level-3 {
position: fixed;
top: 20px;
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: normal;
line-height: 15px;
letter-spacing: 0em;
text-transform: uppercase;
}