floating back to top button html code example
Example 1: javascript go to top of page
window.scroll({
top: 0,
left: 0,
behavior: 'smooth'
});
Example 2: javascript go to top of page
window.scroll({
top: 0,
left: 0,
behavior: 'smooth'
});
window.scroll({top: 0, left: 0});
$('html,body').scrollTop(0);
$('html, body').animate({ scrollTop: 0 }, 'fast');
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()
})