The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript How to add a “selected” class to an external anchor link

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #38563

    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:


    $('#main_menu li ul a').click(function(){
    $('#main_menu li ul a').removeClass('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 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.


    Resolved. Thank you.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.