jQuery Smooth Scroll Current/Active

Go To StackoverFlow.com

0

I'm using jQuery Smooth Scroll on a one page website, and each "panel" has the nav at the top right. I would like to show the currently selected "panel" by highlighting that selection in the nav each time the user changes "panels". Is there a somewhat simple way already built into the plugin to do that? Thanks!

jQuery Smooth Scroll website

2012-04-05 20:56
by ansarob


0

Assuming each of your nav button share the same class (such as .navbutton) but have a different id (such as #nav1,#nav2,#nav3), you could create a new class in your css (lets call it .selected)

.selected {
    background: red;
}

Then, when you execute your code that does your scrolling, also do this:

$(".navbutton").each(function(){ $(this).removeClass('selected'); }); // remove selected from all Nav Buttons
$("#nav1").addClass('selected'); // Add class to single Nav Button (assuming nav1 was clicked)
2012-04-05 21:11
by Applehat
I ended up not needing this functionality, but thank you for the response. It looks like your code would work if I needed it though. Thanks! : - ansarob 2012-04-22 23:58
No problem. Always glad to help - Applehat 2012-04-30 17:28
Ads