问题
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