【发布时间】:2018-09-07 13:00:37
【问题描述】:
这可能是一个简单的问题,但我需要一些帮助。
我有这个代码:
var lastitem='';
(function($) {
var allPanels = $('.accordion> dd').hide();
$('.accordion > dt > a').click(function() {
allPanels.slideUp();
if ($(this).text() != lastitem) {
$(this).parent().next().slideDown();
lastitem = $(this).text();
$(this).get(0).scrollIntoView({
behavior: "smooth", // or "auto" or "instant"
block: "start" // or "end"
});
} else {
lastitem = '';
};
return false;
});
})(jQuery);
我有一个固定的标题,所以当我点击手风琴时,它会滚动到视口中,问题是我的固定标题。我需要从顶部滚动到视口 + 100px。
类似:
$(this).get(0).scrollIntoView({
behavior: "smooth", // or "auto" or "instant"
block: "start + 100px" // or "end"
});
就是这样,有什么建议吗?谢谢!!
【问题讨论】:
标签: javascript jquery scroll scrollview