How to set scrollbar to top of section / forget scroll position

拜拜、爱过 提交于 2020-01-06 13:54:13

问题


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.

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.


回答1:


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




回答2:


set the scrollTop-property of the element to 0



来源:https://stackoverflow.com/questions/6164642/how-to-set-scrollbar-to-top-of-section-forget-scroll-position

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!