In the case, the idea was that each new "post" would overwrite the previous so that the most recent one is always at the top of the story.
Exampleofresultseeninhistory
InthecaseofthecodesallIdidwas:
CSS
div#newDivSpace{border:1pxsolid#aaa;min-height:30px;width:240px;margin-top:10px;margin-left:5px;}.post{margin-bottom:1px;padding:5px;border-bottom:1pxsolid#aaa;}
HTML
<formaction="#">
<input type="text" id="userText">
<button type="button" id="divGenerator" onclick="newDiv()">Criar div</button>
</form>
<div id="newDivSpace"></div>
Javascript
var input = document.getElementById("userText");
var button = document.getElementById("divGenerator");
var space = document.getElementById("newDivSpace");
var post = document.getElementsByClassName("post");
function newDiv() {
var newDiv = document.createElement("div");
var userInput = input.value;
if (userInput != "") {
newDiv.innerHTML = userInput;
newDiv.classList.add("post");
space.appendChild(newDiv);
input.value = "";
}
If you can help with the implementation of a system where the most recent message is always at the top of the history, it will be a great help.