Alex Rivera | Logout

JQuery scroll to top of page

Asked 2010-02-16T18:27:30.047
34

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());
Edit
Report

1 Answer

77

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.

answered 2010-02-16T18:28:25.817

Your Answer