javascript - Cant get HTML chat autoscroll to work -


i have simple html & js chat, , tryed alot of solutions how make auto scroll down when new message recived. nothing works me dont know why.. html divs:

<div id="chat-text" style="width:500px;height:100px;overflow-y:scroll">     <div><strong>welcome game</strong></div>     <div>server: type messages here.</div> </div>  <form id="chat-form">     <input id="chat-input" type="text" autocomplete="off"        style="width:500px"></input> </form> 

my javascript function

socket.on('addtochat',function(data){    chattext.innerhtml += '<div>' + data + '</div>'; });  chatform.onsubmit = function(e){         e.preventdefault();         if(chatinput.value[0] == '/'){             if(chatinput.value == '/getbigger'){socket.emit('biggercheat');}             if(chatinput.value == '/getfaster'){socket.emit('fastercheat');}         }         else {             if(chatinput.value != ''){                 socket.emit('sendmsgtoserver',chatinput.value,nickname);             }         }         chatinput.value = ''; } 

what should when new message recived / sent scroll down, ( want scroll if want read older messages , scroll down when new message recived)

thanks


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -