此脚本可滚动到顶部,如何更改为向下滚动。
这是我的剧本:
$(document).ready(function(){
//Check to see if the window is top if not then display button
$(window).scroll(function(){
if ($(this).scrollTop() > 100) {
$('.scrollToTop').fadeIn();
} else {
$('.scrollToTop').fadeOut();
}
});
//Click event to scroll to top
$('.scrollToTop').click(function(){
$('html, body').animate({scrollTop : 0},800);
return false;
});
});
答案 0 :(得分:0)
这会使用jQuery
将窗口设置为页面底部的动画 $("html, body").animate({ scrollTop: $(document).height() }, 1000);
答案 1 :(得分:0)
你可以试试这个
$("#DIV1").animate({
scrollTop: $('#DIV2').offset().top - $("#DIV1").offset().top + $("#DIV1").scrollTop()-80
},800);
这里DIV2是你要滚动的DIV,而DIV1是你要滚动的地方。
通过将值80更改为不同的值,您可以在任何位置滚动
向上或向下滚动增加或减少值..
希望适用于你