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

Home Forums JavaScript jQuery – Target Active Tab Link?

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


    Using LocalScroll, I’ve been able to make the navigation, so that when you click on a link, that link is highlighted with a class of “current_page_item”, but the problem is, when a user is taken to a link like this:

    Without doing anything, the link in the sidebar doesn’t have a class of “current_page_item”, in this case, it would be bold and green. Right now, the script I’m using only adds the class when that link is clicked. Is there anything I can do?



    When you load the page, you could get whatever hash you may have, and use that to put the class on the appropriate item. It would look something like this:

    var hash = window.location.hash;
    $('a[href="' + hash + '"]').addClass("current_page_item");

    I haven’t tested this, but that should work if you fire it off on page load.


    Hmm, I read the question a bit differently. I’m guessing you want the menu to update as you scroll down the page as well?

    Check out these jQuery plugins:
    * Waypoints
    * VisualNav

    Edit: LOL nevermind, I didn’t look at your page… So, WCMiller has the answer you need then! But I think adding the ability to use the mouse wheel would be nice ;)

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