How can I implement the functionality scroll-to-top
without jquery?
As shown in the picture
$('html, body').animate( { scrollTop : 0 }, 800 );
I want to achieve something as shown on this page but without jquery https://cybmeta.com/scroll-up-jquery
You can assign the use of the method
scrollTo()
HTML button
JS code
This method receives 2 values, which are equivalent to the coordinates in pixels within the document where it will be positioned.
Thanks to @anayarojo's recommendation, I checked and to achieve the hover effect (albeit with CSS) you can use property:
scroll-behavior
with a property calledsmooth
Leaving the final code like this:
I preferred to consult links with a better reputation than the recommended one, but thanks to whoever made the observation.