jQuery simple slide to top animation

How to scroll to the top of the page using a jQuery

Very simple code that you can add to your main.js file listening for a click event on $(‘a.top-page’), a link at the foot of the page.

// Footer ‘Top of the page’
// gives a clean / simple animated slide to the page top
$(‘a.top-page’).click(function(e) {

$(‘html, body’).animate( { scrollTop: 0 }, 1000 );


To alter the speed of the slide, change the 1000 (1000 milliseconds = 1 seconds) to a higher or lower number:
500 = half a second
or use strings
‘fast’ and ‘slow’.