Twitter Bootstrap scrollspy always selecting last element

后端 未结 13 1570
旧巷少年郎
旧巷少年郎 2020-12-08 04:22

I have an issue with scrollspy, recreated in this fiddle: http://jsfiddle.net/jNXvG/3/

As seen in the demo, the ScrollSpy plugin always keeps the last menu item sele

相关标签:
13条回答
  • 2020-12-08 05:24

    When calling the scrollspy method you typically specify the body tag and the nav element.

    <script>
            $(function() {
                $('body').scrollspy({ target: '#faq_sidebar' });
            });
    </script>
    

    The JavaScript above is equivalent to:

    <body data-spy="scroll" data-target="#faq_sidebar">
    

    The only situation where you do not specify the body tag is if you want to track an element with a nested scrollbar like in the JSFiddle above.

    0 讨论(0)
提交回复
热议问题