I am currently working on creating a mock "chat" feature. The issue I am facing is that when I repeatedly click the "send" button, the text overflows from the div. Is there a way to prevent this by stopping the text near the border of the div or adding a scrolling feature? I can only use HTML, JavaScript, and CSS.
function postChat(){
var node = document.createElement("p");
var content= document.getElementById("comment").value;
var comment= content;
var textNode = document.createTextNode(comment);
node.appendChild(textNode);
document.getElementById("allComment").appendChild(node);
}
#chatbox {
width:50%;
text-align:left;
background-color:#F7F7F7;
height:250px;
border:1px solid black;
}
<body>
<div id="chatbox">
<div id="allComment" style="font-size:10px; line-height:90%;" ></div>
</div>
<p>
<input type="text" id="comment" />
</p>
<input type="button" value="Send" onclick="postChat()" />
</body>