Open snaag opened 2 years ago
scrollTop + clientHeight = scrollHeight
.scrollTop = scrollHeight - clientHeight
const ul = document.querySelector('#log');
// ...
const li = document.createElement('li');
li.innerText = text;
ul.appendChild(li);
const { scrollHeight, clientHeight } = ul; // ⭐️
ul.scrollTop = scrollHeight - clientHeight; // ⭐️