如何将滚动条设置到部分顶部/忘记滚动位置 [英] How to set scrollbar to top of section / forget scroll position

查看:352
本文介绍了如何将滚动条设置到部分顶部/忘记滚动位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery UI手风琴.一节具有滚动条.我希望每次打开该部分时,该滚动条默认为顶部.当前,它记住"其先前的位置.有没有办法让它忘记其位置或始终默认为顶部.我只想为特定部分而不是整个页面设置此内容.

I am using jQuery UI Accordion. One section has a scroll bar. I would like that scroll bar to default to the top every time that section is opened. Currently, it "remembers" its previous position. Is there a way to make it forget its position or always default to the top. I only want to set this for the particular section, not the entire page.

帖子建议使用window.scrollTo(0, 0);强制页面滚动到顶部.但是我不确定如何仅将其应用于特定部分.

This post suggests using window.scrollTo(0, 0); to force the page to scroll to the top. But I'm unsure how to apply that to only a particular section.

推荐答案

在手风琴的change或changestart事件中,您可以将.ui-accordion-content的滚动位置设置为0.

You can set the scroll position of .ui-accordion-content to 0 at the accordion's change or changestart event.

这篇关于如何将滚动条设置到部分顶部/忘记滚动位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆