How to scroll to the top of the page in jQuery

To scroll to the top of the page in jQuery you can use the following snippet. This will scroll smmooth to the top of the page, for a instant scroll look at the Javascript Version.

Sample jQuery

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

2 thoughts on “How to scroll to the top of the page in jQuery

Leave a Reply