JQuery scroll to top of page

jquery

Solution

Try this:

$('html, body').animate({scrollTop: '0px'}, 300);

You can do this with `0` instead of `300` to be instant, but this gives a quick auto-scroll effect.

Problem

Is there a way to programmatically scroll to the top of a page with jQuery? I am currently trying to do this with the following code but it is not working. I am using Firefox currently, ``` $(window).scrollTop($(document).height()); ```

Original source