DEV Community

Cover image for Scroll to Top Button using HTML CSS & JQuery

Scroll to Top Button using HTML CSS & JQuery

Divinector on November 18, 2020

Most websites nowadays add a scroll to top button on their websites. Sometimes landing page websites could be long in height, and when a visitor sc...
Collapse
 
cwraytech profile image
Christopher Wray

In my opinion, the best way to do this is by adding an ID to the NAV bar and just linking to the ID from a button at the bottom.

Collapse
 
starryepidemic profile image
StarryEpidemic

Yeah that would be way easier and with bootstrap itll add animations too...

Collapse
 
cwraytech profile image
Christopher Wray

Yes. It’s also better for the user experience because that is what you are doing… Moving to another section on the page. With JavaScript and doing it this way it could be very confusing to screen readers.

Thread Thread
 
starryepidemic profile image
StarryEpidemic

Also bootstrap is way easier than that method and almost does it better than that method so we wont have to unnecessarily debug the code if smth goes wrong just go to the docs view the syntax type it out with the classes...

Collapse
 
yellow1912 profile image
yellow1912

Absolutely no need to use bootstrap for this. It makes sense if you already use bootstrap for the whole site, but makes no sense to include 1 huge library for such a simple thing.

Thread Thread
 
starryepidemic profile image
StarryEpidemic

No but who doesnt use bootstrap

Collapse
 
yellow1912 profile image
yellow1912

Why jQuery when you have native support for this? developer.mozilla.org/en-US/docs/W... and developer.mozilla.org/en-US/docs/W...