Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

John444

macrumors member
Original poster
Feb 10, 2011
90
0
Hello everybody, I am trying to make a website that is entirely on one page. I would like it to, as you scroll down, change the colour of the corresponding menu button to that section of the website.

For example say the person scrolls down to the contact section, as soon as that contact section is reached, I want the contact button to turn blue. Like wise as they scroll back up to the home page section, for the home button to turn blue. However as they leave one section, it turns back to normal.

Any idea how I would do this?
 
Untested... adds a CSS class named "scrolled" to button with ID of "buttonID" when you get to anchor with ID "anchorID". Explore the Waypoints examples and documents for further info.

Code:
$('#anchorID').waypoint(function() {
   $('#buttonID').addClass('scrolled');
});

Hope that helps!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.