Hello. I have a wordpress menu wherein the submenu items are actually jumplinks to anchors on a new page. For example, all the submenu items for the parent link ‘About Us’ are really linking to one page, to the corresponding anchor.
Once I’m ON the ‘About Us’ page, I am able to highlight all the active links with addClass on click. But here is my problem….
I don’t know how to highlight the link when you’ve clicked on it from a separate page. I can only get it to work when jumping within the page. It’s like I need to somehow pass through a class to the selected/active link on page load?
Here is my code now, which works for highlighting links within the page:
$(document).ready(function(){
$('#main_menu li ul a').click(function(){
$('#main_menu li ul a').removeClass('active');
$(this).addClass('active');
});
});
Do you know what I need to do to get it to add the active class or something when jumping to a new page? (The url is like http://www.mysite.com/about#anchor) I really appreciate any help you can give. The site is due to my client tomorrow and I just can’t get this last piece to work! Argh.
Thanks so much.