使用jQuery手风琴控件,如何将其滚动到屏幕上所选的项目?
什么时候:
>我有一个手风琴项目,内容大于可视窗口
>我向下滚动到第二个手风琴项目
>我点击第二个手风琴项目显示它
>第一个手风琴选项折叠,第二个打开,但滑过屏幕。
是否有选择手风琴滚动到第二个项目?
您可以尝试使用scrollTo jQuery plugin.它可以让你做这样的事情:
$.scrollTo('div#foo'); // scroll the browser window so div#foo is in view
$('div#foo').('#bar'); // scroll within div#foo so #bar is in view
将ScrollTo()绑定到手风琴激活事件,如下所示:
$('#youraccordion').bind('accordionactivate', function(event, ui) {
/* In here, ui.newHeader = the newly active header as a jQ object
ui.newContent = the newly active content area */
$( ui.newHeader ).ScrollTo(); // or ui.newContent, if you prefer
});
手风琴激活事件何时触发?
Triggered after a panel has been activated (after animation completes). If the accordion was previously collapsed,
ui.oldHeader
andui.oldPanel
will be empty jQuery objects. If the accordion is collapsing,ui.newHeader
andui.newPanel
will be empty jQuery objects.
参考文献:jQuery UI Accordion
相关文章
- javascript - Bootstrap手风琴,在点击时滚动到活动(开放)手风琴的顶部?
- javascript - AngularJS/ui-bootstrap手风琴 - 点击时滚动到活动(开放)手风琴的顶部
- jQuery手风琴,将点击标签的开头滚动到顶部,如果展开的标签位于被点击的标签上方,则不起作用?
- javascript - jQuery手风琴 - 打开pageload的特定部分
- jquery - 如何将可滚动div中的项目滚动到顶部
- javascript - jQuery UI手风琴,保持多个部分打开?
- jquery - 引导崩溃 - 转到打开的项目的顶部?
- 保持当前jQuery手风琴窗格在ASP.NET回发后打开?
转载注明原文:jQuery手风琴 – 它会滚动到打开的项目的顶部吗? - 代码日志