Show active page in tree menu with JQuery
-
Hi, i’m using jquery to toggle tree menu in sidebar and it’s working fine – the menu is shown on first level categories and i can click and navigate through tree menu.
The problem is when I open page the menu is closed and only first level links are shown. I would like to have the active page (the one that is opened) shown in navigation.
For example, if the default first level sidebar menu looks like this:
menu1
menu2
menu3and i click and navigate to a subpage3 of menu2, i want to have the menu opened to that subpage3
menu1
menu2
– subpage1
– subpage2
– subpage2
menu3The code I’m using:
<script type=”text/javascript”>
$(function(){
$(‘#nav-menu’).find(‘ul li ul’).hide();
$(‘#nav-menu’).find(‘li a’).click(function(e){
$(this).parent().children(‘UL’).toggle();
});
});
</script>Any help would be appreciated. As you can see, I’m pretty new at this and trying to figure it out.
- The topic ‘Show active page in tree menu with JQuery’ is closed to new replies.