JSFiddle - React, Tailwind, and code Playground
by JamesKovacs
HTML
<button>Scroll to the bottom</button>
CSS
button {
position: fixed;
top: 10px;
right: 10px;
}
JavaScript
for(var i = 100; i--;)
$('body').append('<br>lol');
$('button').click(function(){
var shouldScroll = $(document).scrollTop() + $(window).height() === $(document).height();
$('<div>added content</div>').appendTo('body');
if(shouldScroll) {
$(window).scrollTop(document.body.scrollHeight);
}
});