JQuery scroll to top of page

Viewed 47922

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());
4 Answers

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.

Related