动画jQuery scrolltop

Geo*_*rge 4 jquery jquery-ui scrolltop jquery-animate

我在jQuery中有一个scrollTop函数,但我无法为其设置动画.可能吗?

$(".loadmore").click(function() {
  $(this).toggleClass("up-arrow", 1000);
  $(window).scrollTop($('.docs').offset().top, 2000);
});
Run Code Online (Sandbox Code Playgroud)

Sas*_*nga 15

你可以用animate()它.

应用于a的示例代码div如下:

//Scroll to bottom
$('div').animate({scrollTop: $('div').get(0).scrollHeight}, 3000);

//$('div').get(0).scrollHeight - will give the full height of div.
//scrollTop - will be used to animate from the current position to page end.
//3000 - will be the duration.
Run Code Online (Sandbox Code Playgroud)

演示可以在这里找到:http://jsfiddle.net/codebombs/GjXzD/