I am designing a single page website and want the fixed nav links to change colour whenever the user scrolls to the specified location. Seems pretty easy to do, I thought it was pretty easy to do, but I am having problems making it work.
I only downloaded the Scrollspy JS Plugin, as I am not using the Twitter Bootstrap CSS. I just require the Scrollspy Plugin.
Could you check this jsFiddle and provide some guidance? I have already checked out the documentation here, but I’ve had no luck. Any help is greatly appreciated 🙂
Ignoring the serious issues with your use of JSFiddle1, and the typographic errors2, the principle things wrong are
<ul>in the navbar, and#welcomeis not an existing element, causing a JS error.Here’s a fixed demo:
JSFiddle
Oh, and you don’t need both data-api and js to initialize the plugin; choose one.
1 Loading Bootstrap 2.0.2 + 2.0.4 at the same time; trying to include a
<body>in the html panel2 Using upperCamelCase on a function that doesn’t need it:
scrollSpy();