Top of the page with jquery

This one liner jQuery snippet will force your browser to go to the top of your page:

JS

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

If you want to add some smooth scrolling:

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

Call form BTN
$(".btnClass").click(function(){
          $(‘html, body’).animate({ scrollTop: 0 }, ‘slow’);
})

Leave a Reply