Get the App
SLTechnology News&Howtos  ›  Development  › 

How jQuery returns to the top button

Shulou Source: shulou.com Published: 2022-06-01 04:51:13 09月22日 Update

This article mainly introduces the jQuery how to return to the top button, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

Return to the top button

Using the animate and scrollTop methods in jQuery, you can create a simple animation that scrolls to the top without a plug-in:

/ / Back to top$ ('.top') .click (function (e) {e.preventDefault (); $('html, body'). Animate ({scrollTop: 0}, 800);}); Back to top

Change the value of scrollTop to change where you want to place the scroll bar. All you really need to do is animate the body of the document in 800 milliseconds until it scrolls to the top of the document.

Note: beware of some misbehaviors of scrollTop.

Thank you for reading this article carefully. I hope the article "jQuery how to return to the Top Button" shared by the editor will be helpful to you. At the same time, I also hope you will support us and follow the industry information channel. More related knowledge is waiting for you to learn!

Tags: Top articles buttons animation documents no subject value location interest at the same time plug-ins methods time is in more friends knowledge editing industry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL MariaDB Apple Xiaomi Shulou Information