Answered by : fazeel-ahmed
const goToTop = () => window.scrollTo(0, 0);
goToTop();
Source : https://dev.to/saviomartin/20-killer-javascript-one-liners-94f | Last Update : Fri, 14 Jan 22
Answered by : strange-swan-dg307ourgd3m
$("a[href='#top']").click(function() { $("html, body").animate({ scrollTop: 0 }, "slow"); return false;
});
Source : https://stackoverflow.com/questions/1144805/scroll-to-the-top-of-the-page-using-javascript | Last Update : Thu, 27 Aug 20
Answered by : friendly-finch-9v29msyfjr14
var myDiv = document.getElementById('containerDiv');
myDiv.innerHTML = variableLongText;
myDiv.scrollTop = 0;
Source : https://stackoverflow.com/questions/10744299/scroll-back-to-the-top-of-scrollable-div | Last Update : Sun, 14 Jun 20
Answered by : smiling-skimmer-98ly45va7nvl
onActivate(event) { // window.scroll(0,0); window.scroll({ top: 0, left: 0, behavior: 'smooth' }); //or document.body.scrollTop = 0; //or document.querySelector('body').scrollTo(0,0) ...
}
Source : https://stackoverflow.com/questions/48048299/angular-5-scroll-to-top-on-every-route-click | Last Update : Wed, 27 Apr 22
Answered by : alimon-pito
// Add an event listener to the button with id "goto-top"
$('#main-chat-content').on('click', '#goto-top', function () { // Scroll to the top of the page window.scrollTo(0, 0);
});
Source : https://chat.openai.com/c/6081b5a4-93b2-4ffd-aff5-d016172a4eb5 | Last Update : Thu, 03 Aug 23
Answered by : colorful-caracal-o6zhnrgob66e
$("#scroll_icon").click(function() { jQuery('html,body').animate({scrollTop:0},2000); })
Source : | Last Update : Thu, 02 Jul 20
Answered by : thoughtful-trout-i27he4xwoa42
yOffset = window.pageYOffset;
Source : https://developer.mozilla.org/en-US/docs/Web/API/Window/pageYOffset | Last Update : Thu, 30 Sep 21
Answered by : rich-rhinoceros-i9ndqct06v35
const scrollToTop = (element) => element.scrollIntoView({ behavior: "smooth", block: "start" });
Source : https://dev.to/ruppysuppy/7-killer-one-liners-in-javascript-one | Last Update : Thu, 21 Apr 22
Answered by : sleepy-starling-z5vlfsjexl0n
$(document).ready(function(){ $(".scroll-top").click(function() { $("html, body").animate({ scrollTop: 0 }, "slow"); return false; });
});
Source : | Last Update : Sat, 31 Jul 21
Answered by : joshua-prize
scrollto top
Source : | Last Update : Wed, 13 Jul 22