First of all, forgive me if this has already been answered, I searched but couldn't find an example relevant to what I'm trying to do.
I have a vertical menu with some sub menus. When the top level menu is clicked the sub menu opens up. The problem is that I would like the sub menu you clicked to stay open when you arrive to the new page. As it is now, when a sub-menu item is clicked and you go to the destination page, the menu collapses.
Here's my code:
<script type="text/javascript" charset="utf-8">
$(function(){
$('#menu li a').click(function(event){
var elem = $(this).next();
if(elem.is('ul')){
event.preventDefault();
$('#menu ul:visible').not(elem).slideUp();
elem.slideToggle();
}
});
});
</script>
And a Fiddle:
Thanks in advance