Hi guys, new member here, so sorry if my question is in the wrong place or in the wrong format. I've got a "primary" menu that leads to a "secondary" menu and I am highlighting it so: jQuery(document).ready(function($) { $("a").each(function() { if ((window.location.pathname.indexOf($(this).attr('href'))) > -1) { $(this).addClass('activeMenuItem'); } }); }); and css so: a.activeMenuItem { background-color: white; font-weight: bold; } This works just fine, but when a user selects an item from the "secondary" menu the highlighting is lost from the "primary" menu. Is there a way to maintain the highlighting on the "primary" menu? Thanks and hello to all in the community!
What the bloody blue blazes are you throwing scripttardery at a menu for?!? ESPECIALLY that steaming dung-heap known as jQuery? Why not just generate the 'current' class server-side like a good little doobie? In the vast majority of cases this is NONE of any client-side scripting's business. But if you could share the full page we could tell your more. Little snippet like that tells us but two things; and Jack left town.
If your pages already using JQuery then go for it . But just to crate a simple menu no need to go for JQuery. However JQuery UI has beautiful Menu with all your required sub menu , highlighting etc ... This is easy to develop also as no need to write all the code.