$('a[href=#top]').click(function(){ $('html, body').animate({scrollTop:0}, 'slow'); return false; });
<a name="top"></a> <p>scroll to bottom of the page and click the "back to top" link</p> <p>===</p> <p>----------------------</p> <p>scroll to bottom of the page and click the "back to top" link</p> <p>===</p> <p>----------------------</p> <p>scroll to bottom of the page and click the "back to top" link</p> <p>===</p> <p>----------------------</p> <p>scroll to bottom of the page and click the "back to top" link</p> <p>===</p> <p>----------------------</p> <p>scroll to bottom of the page and click the "back to top" link</p> <p>===</p> <p>----------------------</p> <p>scroll to bottom of the page and click the "back to top" link</p> <p>===</p> <p>----------------------</p> <p>scroll to bottom of the page and click the "back to top" link</p> <p>===</p> <p>----------------------</p> <p>scroll to bottom of the page and click the "back to top" link</p> <p>===</p> <p>----------------------</p> <p>scroll to bottom of the page and click the "back to top" link</p> <p>===</p> <p>----------------------</p> <p>scroll to bottom of the page and click the "back to top" link</p> <p>===</p> <p>----------------------</p> <p>scroll to bottom of the page and click the "back to top" link</p> <p>===</p> <p>----------------------</p> <p>scroll to bottom of the page and click the "back to top" link</p> <p>===</p> <p>----------------------</p> <p>scroll to bottom of the page and click the "back to top" link</p> <p>===</p> <p>----------------------</p> <p>scroll to bottom of the page and click the "back to top" link</p> <p>===</p> <p>----------------------</p> <p>scroll to bottom of the page and click the "back to top" link</p> <p>===</p> <p>----------------------</p> <p>scroll to bottom of the page and click the "back to top" link</p> <p>===</p> <p>----------------------</p> <p>scroll to bottom of the page and click the "back to top" link</p> <p>===</p> <p>----------------------</p> <p>scroll to bottom of the page and click the "back to top" link</p> <p>===</p> <p>----------------------</p> <p>scroll to bottom of the page and click the "back to top" link</p> <a href="#top">back to top</a>