js scroll up code example
Example 1: scrool to top jquerry
$("a[href='#top']").click(function() {
$("html, body").animate({ scrollTop: 0 }, "slow");
return false;
});
Example 2: scroll down up js
var lastScrollTop = 0;
element.addEventListener("scroll", function(){
var st = window.pageYOffset || document.documentElement.scrollTop;
if (st > lastScrollTop){
} else {
}
lastScrollTop = st <= 0 ? 0 : st;
}, false);
Example 3: scroll through page with javascript
window.scroll({
top: 0,
left: 0,
behavior: 'smooth'
});
Example 4: scroll to top
$("#scroll_icon").click(function()
{
jQuery('html,body').animate({scrollTop:0},2000);
})