2013-02-28 99 views

回答

2

你不需要插件:

$('button').click(function(){ 
    $('html,body').animate({ scrollTop: 0 }, 1000); 
}); 

您還可以使用:

$('html,body').animate({ scrollTop: $("element").offset().top }, 1000); 

其中element是頁面上的元素。然後它將滾動到該元素的位置。將1000更改爲您希望動畫跨越的毫秒數。 1000 = 1秒。