Reputation: 867
Ok so I'm trying to create a vertical sliding and I got one to almost work the way I want. It's a really simple code. There's 3 problems though:
Here's the code: THANKS!
<script type='text/javascript'>
$(document).ready(function(){
$("nav.main_menu li").hover(function(){
$(this).children("ul").slideDown(500);
},function(){
$(this).children("ul").slideUp(300);
});
});
</script>
<nav class="main_menu">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">News</a>
<ul class="sub-menu">
<li><a href="#">Events</a></li>
<li><a href="#">Updates</a></li>
</ul>
</li>
<li><a href="#">People</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Gallery</a>
<ul class="sub-menu">
<li><a href="#">2009</a></li>
<li><a href="#">2010</a></li>
<li><a href="#">2011</a></li>
<li><a href="#">2012</a></li>
<li><a href="#">2013</a></li>
<li><a href="#">2014</a></li>
<li><a href="#">2015</a></li>
</ul>
</li>
<li><a href="#">Contact</a></li>
<li><a href="#">Bio</a></li>
</ul>
</nav>
Upvotes: 0
Views: 2457
Reputation: 1878
display:none;
or do $("li ul").hide();
inside of the .ready()
function before you define the hover bit.li
elements span a much larger portion of the page than is visible. You may want to check out your CSS for them and limit the height or width of them. So long as overflow:hidden
isn't set, the submenus should still appear.Upvotes: 4