Javascript 搜索时自动向下滚动
我有一个jsp页面,其中有一些隐藏的内容Javascript 搜索时自动向下滚动,javascript,jquery,Javascript,Jquery,我有一个jsp页面,其中有一些隐藏的内容 onclick我所拥有的搜索按钮可以显示很多内容 但我想要一个自动向下滚动,这样用户就不必承担向下滚动的负担 我希望我是尝试此功能,它将向下滚动到要显示的元素级别以进行搜索 // clicking the "down" button will make the page scroll to the $elem's height $('#elem').click( function (e) { $('html, body').ani
onclick
我所拥有的搜索按钮可以显示很多内容
但我想要一个自动向下滚动,这样用户就不必承担向下滚动的负担
我希望我是尝试此功能,它将向下滚动到要显示的元素级别以进行搜索
// 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);
}
);
你能提供一个例子吗?使用
$('html,body').animate()
可以让Opera分别滚动每个页面。。。看看这个
$('#search_button').click(function () {
var offset = $('#element_where_you_want_to_scroll_to').offset().top;
$('html,body').animate({
scrollTop: offset
}, 100);
});