I am working on a chat application and I have a background where the messages should be displayed. To not just have simple overflow I added this line to css: overflow-y: scroll;
which will add a scroll bar. This all works fine, but is there a way to automatically scroll to the bottom, where the newest messages are. It can also be in JavaScript.
My html code looks like this:
<article id="chat">
<script src="chat.js"></script>
</article>
Each message will have this form and gets added into the article:
"<p class='msg'>" + msg + "</p>"