I am currently working on a project that will not allow for jQuery and I am very new to JavaScript and OO programming as a whole (Two weeks). You can see the entirety of the project in the following repo: https://github.com/Sntax/jsChat/blob/master/script.js
Basically I am creating a simple chat app as a learning project. I am injecting HTML into a div onClick or Enter/Tab using:
var jsChat = {
username: document.getElementById('username'),
comment: document.getElementById('comment'),
output: document.getElementById('output'),
};
function postData(){
jsChat.output.innerHTML += '<div class="username">' + jsChat.username.value + ':' + '</div>';
jsChat.output.innerHTML += '<div class="comment">' + jsChat.comment.value + '</div>';
clearContent();
}
Right now it will print to the div successfully but once the "comments" become too long for the div-height, they will auto scroll off the bottom of the page and out of sight. I am wanting to setup a way to force the scroll to "scroll down" to the bottom of the div so that it rather scrolls old chat comments off the top of screen much like a normal chat application.
Ninja Edit: I tried throwing the following into the postData() function to no avail:
jsChat.output.scrollTop = 99999;