scroll to top html code example
Example 1: javascript go to top of page
window.scroll({top: 0, left: 0});
$('html,body').scrollTop(0);
$('html, body').animate({ scrollTop: 0 }, 'fast');
Example 2: scroll to top
$("#scroll_icon").click(function()
{
jQuery('html,body').animate({scrollTop:0},2000);
})
Example 3: simple button scrolling with this
$('#id a').on('click', function (e) {
var href = $(this).attr('href')
$('html, body').animate({
scrollTop: $(href).offset().top
}, '300')
e.preventDefault()
})