JQuery toggle active menu item depending on page?

You'll have to fill in the bit that actually shows the menu, though. Let me know if you need help with that as well.

$("#menu a"). Each(function() { if($(this). Attr('href') == window.location.

Href) { //Show the menu. } }); You'll have to fill in the bit that actually shows the menu, though. Let me know if you need help with that as well.

I tested it briefly in the Chrome Javascript console and it seemed to find the correct element. Be sure to test it across multiple browsers, though. I think this also relies on the href element in each link being a "full" URL including the and the domain name.

If they are relative links (e.g. /home) you'll want to use window.location. Pathname instead of window.location.href.

This works great. I added $(this).parent().parent().children().show(); to get the menu functionality to work, and it's live! Thanks very much.

I think all the other suggestions would have worked as well, but this was the easiest to do without recoding everything. Thanks. – steve Feb 10 at 17:11 @steve No problem!

– Riley Dutton Feb 10 at 20:57 awesome, the pathname worked in my case – zaladane May 12 at 16:23.

You can add a certain class for the element with PHP, and then find the element with jQuery and show it. For example: ">Page 1 ">Page 2 ">Page 3 Then with jQuery: $('#menu . Container ul li.

Active:first-child'). Click(function() { $(this).siblings().fadeToggle(); }) If the menu is printed with PHP automatically, it could be easily implemented. Other approach - don't hide the selected menu in the first place, so it is instantly expanded :).

I see you've got a body class on section-n on each page. If you can apply a class to the ul of each parent menu item you'll be able to show or hide the sub-menu using . Menuparent ul { display: none; } .

Bodyclass . Menuparent ul { display: block; } --edit-- Just seen that it's not coded in this way: menu parent menu sub 1 menu sub 2 Which would be required for my answer to work. Probably a better way to code it up if you can as it's a parent-child menu system.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions