自动向下滚动搜索

时间:2011-07-13 08:53:51

标签: javascript jquery

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

搜索按钮的

onclick我显示了很多内容。

但我希望自动向下滚动,这样用户就不必担心向下滚动。

我希望我是

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

尝试此功能,它将向下滚动到您正在搜索的ELEMENT级别。

// 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);
    }
);
相关问题