Automatically web page scroll using JQuery

Sometimes we need to scroll the page automatically back to the top when the page is loaded.

So, Here I will use some JQuery code to scroll the page to the top automatically.

I will show two types of scrolling the web page.

Using some animation.

<
script type="text/javascript">

        jQuery(document).ready(function () {

            $('html, body').animate({ scrollTop: 0 }, 'slow');

            return false;

        });

</script>

 
The above code will scroll the page to top with slow animation.

Other method.

<script type="text/javascript">

        $(document).ready(function () {

            window.scrollTo(0, 0);

        });

</script>

The above will also scroll the web page to top without any animation and saves scrolling time to the top if your page is long.
  

Ebook Download
View all
Learn
View all