在不使用动画的情况下滚动到按钮单击顶部 [英] Scroll to top on button click without using animate

查看:61
本文介绍了在不使用动画的情况下滚动到按钮单击顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在不使用animate功能的情况下滚动到按钮单击顶部。我需要在没有一次等待的情况下向上滚动。

Scroll to top on button click without using the animate function. I need to go to scroll up without having a single time to wait.

推荐答案

如果您不需要动画,请不要使用jQuery - 使用纯JavaScript ...

window.scrollTo(x,y)会这样做...

然而这个(以及所有其他滚动方法) )不是任何标准的一部分...

最标准的方法是在页面顶部放置一个锚点,使按钮指向该锚点...
If you not need animation do not use jQuery - use plain JavaScript...
window.scrollTo(x,y) will do it...
However this (and all the other scroll methods) are not part of any standard...
The most standard way is to put an anchor at the top of your page and make the button point to that anchor...


这篇关于在不使用动画的情况下滚动到按钮单击顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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