Smooth scroll back to top button

LANGUAGES

Posted on 2014-11-26 02:17:32


jQuery(document).ready(function($) 
{ 
    $(".scroll").click(function(event)
    {
        event.preventDefault();
        $('html,body').animate({scrollTop:$(this.hash).offset().top}, 500);
    });
});

Code html with add a link

<a href="#top" class="scroll">Back to top</a>

href=”#top” ⇒ when you click to link which will scroll to id = "top"