我对在这个小提琴中重新创建的 scrollspy 有疑问:http://jsfiddle.net/jNXvG/3/
I have an issue with scrollspy, recreated in this fiddle: http://jsfiddle.net/jNXvG/3/
正如演示中所见,无论滚动位置如何,ScrollSpy 插件始终保持最后一个菜单项被选中.我已经阅读了其他问题和答案,并尝试了 offset 等的不同组合,但没有一个有帮助.我不知道出了什么问题.
As seen in the demo, the ScrollSpy plugin always keeps the last menu item selected no matter the scrolling position. I've read other questions and answers and tried different combinations of offset, etc., but none of them have helped. I can't figure out what's wrong.
我不想编辑我的模板来包含丑陋的 html 'data' 标签,所以我通过 JavaScript 调用 scrollspy() 来激活插件.
I don't want to edit my template to include ugly html 'data' tags, so I am calling scrollspy() via JavaScript to activate the plugin.
下一步是移除固定的内容高度并在侧边栏使用 'affix'.
The next step would be to remove the fixed content height and use 'affix' on the sidebar.
您需要将 ScrollSpy 附加到将要触发滚动事件的元素,而不是要反映滚动位置的菜单:
You need to attach the ScrollSpy to the element that is going to trigger scroll events, rather than the menu that is going to reflect the scroll position:
$('#content').scrollspy();
这篇关于Twitter Bootstrap scrollspy 总是选择最后一个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
用于创建头像的 jQuery/JavaScript 库?jQuery/JavaScript Library for avatar creation?(用于创建头像的 jQuery/JavaScript 库?)
如何做以下掩码输入问题?How to do following mask input problem?(如何做以下掩码输入问题?)
使用 DropKick Javascript 设置值/标签的问题Issues Setting Value/Label Using DropKick Javascript(使用 DropKick Javascript 设置值/标签的问题)
如何对 jquery 插件中的私有方法进行单元测试?how to unit-test private methods in jquery plugins?(如何对 jquery 插件中的私有方法进行单元测试?)
stellar.js - 为垂直滚动网站配置偏移量/对齐元素stellar.js - configuring offsets / aligning elements for a vertical scrolling website?(stellar.js - 为垂直滚动网站配置偏移量/对齐元素?)
jQuery 屏蔽输入插件.当文本框获得焦点时选择所有jQuery masked input plugin. select all content when textbox receives focus(jQuery 屏蔽输入插件.当文本框获得焦点时选择所有内容)