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);
}
);
精彩评论