jquery - 动画返回页面顶部点击 [英] jquery - Animated return to top of page on click

查看:59
本文介绍了jquery - 动画返回页面顶部点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望动画滚动效果,以便在单击元素时将用户带到页面顶部。有点像锚定到页面的顶部,但更顺畅。

I want to animate a scroll effect to take a user to the top of the page when clicking on an element. A bit like anchoring to the top of the page but smoother.

我已经看到这样做了(不记得在哪里)。

I've seen this done (can't remember where though).

有谁知道如何做到这一点?

Does anyone know how this can be done?

推荐答案

你想 .animate() scrollTop 属性为 0 ,如下所示:

You want to .animate() the scrollTop property to 0, like this:

$("html, body").animate({ scrollTop: 0 }, 500);

这篇关于jquery - 动画返回页面顶部点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆