4 years ago (2014-05-18 21:27:30)

Smooth Scrolling with jQuery on Page Classes and ID clicks

3 0
136

Going to Top of the Page or Bottom, or at exact point developers use # tags for IDs but scroll action for that is so quick and dirty {in a designer way}. So here is a small quick snippet to just copy and paste on page where you want smooth gesture scroll on link click, it works with classes.

<script>

$(document).ready(function() {

     $('.go-top').click(function(){

          $("html, body").animate({ scrollTop: 0 }, 600);

     return false;

     });

});

<script>

the scrollTop is the position where you want your scrollar to stop in pixels and 600 is the animation speed to that position, you can change it to your choice of scroll.

use it as:

<a class="go-top">Go to Page Top</a>

The Famous text seen on most of new Websites. It will definitely work, try to make new changes.

Sign up or Sign in for free.
And start a new thread.
No Threads
More notes by Ankit Gupta