自动向下滚动搜索

automatic scroll down on search

本文关键字:滚动 搜索      更新时间:2023-09-26

我有一个jsp页面,其中有一些内容是隐藏的。

onclick的搜索按钮我已经显示了很多内容。

但是我想要一个自动向下滚动,这样用户就不必承担向下滚动的负担。

我希望我是

$('#search_button').click(function () {
  var offset = $('#element_where_you_want_to_scroll_to').offset().top;
  $('html,body').animate({
    scrollTop: offset
  }, 100);
});

试试这个函数,它将向下滚动到您要显示搜索的元素级别。

// clicking the "down" button will make the page scroll to the $elem's height
$('#elem').click(
    function (e) {
        $('html, body').animate({scrollTop: $elem.height()}, 800);
    }
);