2

Fiddle: http://jsfiddle.net/bVLBL/

The class "active" is not applied to the proper link. Any ideas how to fix this?

HTML:

<div data-spy="scroll" data-target="#navbar">
    <div id="navbar" data-spy="affix" class="sticky-nav">
        <ul class="nav inline">
            <li><a href="#introduction">Introduction</a></li>
            <li><a href="#products">Products</a></li>
            <li><a href="#company">Company</a></li>
        </ul>
    </div>
    <div class="sections"> 
        <section id="introduction" name="introduction">Test1</section>
        <section id="products" name="products">Test2</section>
        <section id="company" name="company">Test3</section>
    </div>
</diV>
DarkLeafyGreen
  • 69,338
  • 131
  • 383
  • 601

1 Answers1

5

It seems to work if you assign the data-spy and data-target attributes to a body tag instead of the containing div.

http://plnkr.co/edit/O1244QqRJEOcRfXCCk5J

urban_raccoons
  • 3,499
  • 1
  • 22
  • 33
  • Why? Sounds unlogical.. I am working with a master layouts file where i write my body tag. It's not clean to have these classes on all the pages, when I only want scrollspy on one (of the 30ish pages that use the same body).. Also: doesn't seem to work for me – nclsvh Sep 04 '17 at 14:33