I want to use Bootstrap ScrollSpy with multiple nav, my main nav and a vertical subnav.
I tried multiple thing like :
<body data-spy="scroll" data-target="#main-nav #subnav">
<body data-spy="scroll" data-target="#main-nav, #subnav">
$('body').scrollspy({target: "#main-nav"});
$('body').scrollspy({target: "#subnav"});
$('body').scrollspy({target: "#main-nav"}, {target: "#subnav"});
- Putting wrapper div:
<body data-spy="scroll" data-target="#main-nav"><div data-spy="scroll" data-target="#subnav">
but nothing worked fine...
How can I acheive this?
Thank you!
I know, that this question is very old, but here my implementation for multiple target scroll-spy. Just use it like this:
<body data-multiple-spy="scroll" data-target="#bs-example-navbar-collapse-1,#features-navbar .navbar-collapse" data-offset="70"</body>
Plugin:
Ok, I found a way to acheive what I want.
If I dont define a target to scrollSpy, all my navigation links are considered :