开发者

automatic scroll down on search

I have a jsp page in which there are some contents which are hidden.

开发者_开发百科

onclick of the search button I have displays much content.

But I want an automatic scroll down so that user doen't have to take the burden to scroll down.

I hope I was


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


Try this function it will scroll down to the level of ELEMENT that you are displaying for search.

// 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);
    }
);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜