js auto scroll to bottom code example
Example 1: how to make auto scroll to the end in css
let objDiv = document.getElementById("divExample");
objDiv.scrollTop = objDiv.scrollHeight;
Example 2: scroll to bottom of div javascript
function scrollSmoothToBottom (id) {
var div = document.getElementById(id);
$('#' + id).animate({
scrollTop: div.scrollHeight - div.clientHeight
}, 500);
}
function scrollToBottom (id) {
var div = document.getElementById(id);
div.scrollTop = div.scrollHeight - div.clientHeight;
}
Example 3: javascript scroll to bottom
const theElement = document.getElementById('elementID');
const scrollToBottom = (node) => {
node.scrollTop = node.scrollHeight;
}
scrollToBottom(theElement);
Example 4: auto scroll to bottom of page js
window.scrollTo(0,document.body.scrollHeight);