"To easily add scrollspy behavior to your topbar navigation, add
data-spy="scroll"
to the element you want to spy on (most typically this would be the<body>
). Then add thedata-target
attribute with the ID or class of the parent element of any Bootstrap.nav
component." -- docs.
Those data-
attributes must be added to whichever element is being scrolled. Unless #mycontent
is overflow:scroll
, you need to add those data-
attributes to your <body>
tag instead.