Simple Scroll to top using JQuery

Link that takes you to the top of the page when you have scrolled down the page

Vivek Arora
Web Design Tutorials
2 min readJun 15, 2014

--

With most of the sites having infinite scroll these days it is important to have a little link somewhere at the bottom of the page which takes the user back to the top of the page. This is a an important piece of functionality especially if the page becomes really long.

We are going to achieve the following -
1) The scroll to top link is hidden when the page loads.
2) When the user starts scrolling, the link fades in and is clickable
3) User can click on the back to top link to scroll back to top and the link fades out.

Live Demo

Lets start with the simple HTML. It is a simple anchor tag with a class “backtop”. This will act as a link to bring the user back to top.

CSS

jQuery

Now lets do the important jQuery part. It uses a simple, easy to understand 15 line jQuery code to achieve the whole thing.

--

--

Vivek Arora
Web Design Tutorials

passionate web guy and constant learner. tweets and blogs tutorials on #webdesign #html #css #jquery #php. follow me @vivekarora86 http://vivekarora.com/blog