jquery smooth scroll to top code example
Example 1: smooth scroll jquery onclick
$("#button").click(function() {
$('html, body').animate({
scrollTop: $("#myDiv").offset().top
}, 2000);
});
Example 2: smooth scroll to top jquery
window.scrollTo({top: 0, behavior: 'smooth'});
Example 3: smooth scroll css
html {
scroll-behavior: smooth;
}
/* No support in IE, or Safari
You can use this JS polyfill for those */
http://iamdustan.com/smoothscroll/