0

我有以下脚本:

$('.how-we-do-it .items div').on('click', function () {
    var $matchingDIV = $('.how-we-do-it .sections .section .content div.' + $(this).attr('class'));
    $matchingDIV.toggle('fast');
});

我一直在尝试添加一些额外的代码,以便页面自动向下滚动到被切换的 $matchingDIV。

我一直在尝试使用 scrollTop 和 Smooth Scroll 插件来完成此操作,但我无法让它与我的 $matchingDIV 输出一起使用。

完成此任务的最简单方法是什么?

4

1 回答 1

2

尝试为and的scrollTop属性设置动画:htmlbody

$("html, body").animate({ scrollTop: $matchingDIV.offset().top }, delay);
于 2013-05-18T21:02:50.727 回答