jQuery scrollTo手风琴结束位置

我在一个页面上有多个手风琴,每个手风琴都有大量的文字。 只能打开一支手风琴。 我有scrollTo插件,当点击手风琴与手风琴的顶部对齐时,我正在为scrollTo制作动画。 如果我有太多文字,则scrollTo不会与手风琴顶部对齐。 有没有办法在动画开始前获得手风琴的结束位置? 或者只是将滚动位置与手风琴对齐的分辨率?

$(".accordion h3").click(function () { var thisTrigger = $("span", this); var thisIntro = $(this).siblings(".intro"); var thisPane = $(this).siblings(".pane"); var otherIntros = $(this).parents(".parentClass").siblings().find(".intro"); var otherPanes = $(this).parents(".parentClass").siblings().find(".pane"); var otherHeaders = $(otherPanes).siblings(".current"); var otherTriggers = $(otherHeaders).find("span"); if ($(this).hasClass("current")) { $(this).removeClass("current"); $(thisIntro).removeClass("open"); $(thisPane).slideUp("fast"); } else { $(this).addClass("current"); $(thisIntro).addClass("open"); $(thisPane).slideDown("fast"); $(otherIntros).removeClass("open"); $(otherHeaders).removeClass("current"); $('html, body').animate({ scrollTop: $(this).position().top }, 500); } }); 

这个链接帮助了我: 如何将滚动条设置到顶部/忘记滚动位置

以下是我的代码:

 //initializes accordion $("#search").accordion({ header: "h3" , fillSpace: true , active: activeIndex , change: function (event, ui) { var index = $(this).accordion("option", "active"); $("[id$=_hdnAccordionIndex]").val(index); $('.ui-accordion-content').scrollTop(0); } });