How to scroll to the top of the page in javascript

To scroll to the top of the page in javascript you can use the following snippet. This will scroll instant to the top left of the page, for a smoot scroll look at the jQuery Version.

Sample Javascript

window.scrollTo(0, 0);

2 thoughts on “How to scroll to the top of the page in javascript

Leave a Reply