JavaScript
Article

jQuery Auto Scroll To Top Of Page

By Sam Deering

jquery-sail-on-up-top-of-page
You can use jQuery to automate a slow scroll to the top of your webpage by using a simple code snippet below. Why?

  1. It saves the user time scrolling to the top if your page is long
  2. It looks cool.

See Live Demo

jQuery scroll to top

jQuery(document).ready(function($) {
	$('a[href=#topbar]').click(function(){
		$('html, body').animate({scrollTop:0}, 'slow');
		return false;
	});
});

Free Guide:

7 Habits of Successful CTOs

"What makes a great CTO?" Engineering skills? Business savvy? An innate tendency to channel a mythical creature (ahem, unicorn)? All of the above? Discover the top traits of the most successful CTOs in this free guide.

  • http://www.joomir.com ahmad balavipour

    thanks alot, very good tutorial. i am using this in my website

  • Jana

    thanks, just what I was looking for :-)

  • Naved Ahmed

    thanks …. but I need automattical scroll… :(

  • Hamza

    automaic scoll needed its not :(

Recommended
Sponsors
Because We Like You
Free Ebooks!

Grab SitePoint's top 10 web dev and design ebooks, completely free!

Get the latest in JavaScript, once a week, for free.