javascript tutorial - [Solved-5 Solutions] Scroll to the top of the page using JavaScript/jQuery - javascript - java script - javascript array
Problem :
How to scroll to the top of the page using JavaScript/jQuery ?
Solution 1:
If we 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.
Parameters
- x-coord is the pixel along the horizontal axis.
- y-coord is the pixel along the vertical axis.
Solution 2:
If we do want smooth scrolling, try something like this:
Solution 3:
Try this to scroll on top
Solution 4:
We don't need jQuery to do this. A standard HTML tag will suffice...
Solution 5:
in html