Scroll to Top of Page with jQuery


 / Published in: jQuery
 

This is a simple way to scroll to the top of the page, when an anchor tag has been clicked. Note that we must "return false," in order to disable the default browser action.

  1. $('#someAnchor').click(function() {
  2. $('html, body').animate({ scrollTop:0 }, 'fast');
  3. return false;
  4. });

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: frysteen on October 1, 2010

Excellent... thanks!

Posted By: frysteen on October 1, 2010

Excellent... thanks!

You need to login to post a comment.