I'm making a one page website and I'm trying to get the navbar links to reflect what section of the page you're on. I've tried using it through HTML with no success. I had this code on the container that contains my different sections
<div class="container" data-spy="scroll" data-target="#navbar">
and the body is set to relative.
Since that wasn't working I tried using Scrollspy with javascript using this
$('.container').scrollspy({ target: '#navbar' })
Also with no luck. I have the jQuery CDN before the bootstrap CDN but I'm getting this error in the console. Uncaught TypeError: $(...).scrollspy is not a function
jQuery
twice. You are missing thebootstrap.js
include in your pen though. Also, you might not see the scroll spy in all it's glory until your sections have content in them. If the sections are very narrow/thin it might look like it skips sections. – Lodie