autoscroll when at bottom js code example
Example 1: javascript auto scroll on overflow to bottom
window.setInterval(function() {
var elem = document.getElementById('data');
elem.scrollTop = elem.scrollHeight;
}, 5000);
Example 2: javascript auto scroll on bottom
const scrollToTop = () => {
const scrollTopButton = document.getElementById('scrollTopButton');
scrollTopButton.addEventListener('click', () => {
window.scrollTo(0, document.body.scrollHeight);
});
};