Frage

The documentation says:

<body data-spy="scroll" data-target=".navbar">...</body>

or

$('#navbar').scrollspy();

I'd like to use this second method (js/jquery). It seems like you're supposed to call .scrollspy() on the nav, and not sure how to specify which element to 'spy' on... Can't get this to work!

War es hilfreich?

Lösung

After a little digging...

The documentation is wrong. As this question points out, you're supposed to use .scrollspy() on the content, not the nav.

But then how do you target the correct nav?

It turns out, you have to target the parent of the ul.nav, and you can pass it to .scrollspy({target: '.navparent'}); like so.

http://jsfiddle.net/G75m3/2/

Hope this helps someone!

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top