Scroll to the top of the page using JavaScript/jQuery?

I've a <button> on the page, when this button is pressed a hidden <div> is shown using jQuery.

How do I scroll to the top of the page using a JavaScript/jQuery command in that function? It is desirable even if the scroll bar instantly jumps to the top. I'm not looking for a smooth scrolling.

Text Copied From
on : Fri, Jul 17, 2009 Views : 1200626

Accepted Answer

If you don't need the change to animate then you don't need to use any special plugins - I'd just use the native JavaScript window.scrollTo method -- passing in 0,0 will scroll the page to the top left instantly.

window.scrollTo(x-coord, y-coord);


  • x-coord is the pixel along the horizontal axis.
  • y-coord is the pixel along the vertical axis.
Text Copied From
on : Fri, Jul 17, 2009

Ask Question

If you want to ask question you must LogIn or SignUp
Login SignUp

Quick Links



Total Followers
Study Group Created
Study Group Joined
Following Teacher
Following Organization
Blog Articles Added
Questions Asked
Questions Answered
Jobs Posted
Total Members in Group
Questions asked by members
Tasks added in this Group

Please wait..


Login to Open ESchool OR Create your account    Login   SignUp