通过jQuery动画减慢滚动到顶部事件 [英] Slow down scroll to top event by jQuery animate
本文介绍了通过jQuery动画减慢滚动到顶部事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
点击某个锚时,我希望我的页面转到顶部。
I'd like my page to go to the top when certain anchor is clicked.
以下是我尝试这样做的方法,但它不起作用,它滚动得非常快。
Here is how I tried to do it but it's not working, it's scrolling super fast.
$('a[href=#top]').click(function () {
$('body').animate({
scrollTop: 0
},
50);
});
我想放慢速度。
推荐答案
$('a[href=#top]').click(function(){
$('html, body').animate({scrollTop:0}, 'slow');
});
或许?
这篇关于通过jQuery动画减慢滚动到顶部事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文