I am doing a chat, but the problem is that when sending a message the scroll should go down, but you should also be able to see the previous messages. This is my code in js:
function Scroll(){
document.getElementById('chat').scrollTop =document.getElementById('chat').scrollHeight;
setInterval(function(){Scroll();},1000);
}
But the only thing he does is go all the way down and when he wants to see previous messages he does not leave