My page is a single page website which has a pageslide navigation on the side which has an id of “navigation”. My main section is a fully fluid 100% wide design and it only changes when a button on the side is pressed to reveal the navigation menu. On this navigation menu, I want to be able to change the class of the links between two classes e.g “active” and “nonactive” and i want this to change depending on the position the user is scrolled at, i.e if the position the user is scrolled at is on the div id of “about”, i want the class in the navigation that links to about to have a class of “active” and the rest of the links as “nonactive”. This will be for every link.
My website is at http://sandbox.modernturtle.com
Any help would be appreciated 🙂
Twitter Bootstrap has a plugin that does this for you. Here is a demo: http://twitter.github.com/bootstrap/javascript.html#scrollspy
EDIT:
Initialize the plugin like so:
Then add the
data-spyattribute to the body tag:And at last (this step you already have on your site), match the navigation link’s
hrefto the div’sid: