I'll risk an adaptation of the code that may be what you want. Following Netinho's answer line , I believe you can solve it. If this is the case, the credits are from Netinho, because I just adapted his code.
var recebeMensagem = []
var mensagemBot = '<div class="bot_mensagens">' + recebeMensagem + '</div>';
var conteudoHtml = '';
conteudoHtml = $('.recebe_as_mensagens').html();
recebeMensagem += 'Olá';
recebeMensagem += 'Tudo bem?';
recebeMensagem += 'Tchau';
conteudoHtml += mensagemBot;
$('.recebe_as_mensagens').html(conteudoHtml);
$(".bot_mensagens").text(recebeMensagem)
Here you have a vector in Javascript recebeMensagem = []
, now you just have to move the items into the vector and the messages will be stored in different positions.
Following the same logic, you can scan your array and display the results as follows:
for(var i = 0; i < recebeMensagem.length; i++){
conteudoHtml = mensagemBot;
$('.recebe_as_mensagens').html(conteudoHtml);
$(".bot_mensagens").text(recebeMensagem)
}
See in JsFiddle
I hope it helps, I just tried to adjust the logic, I do not have much experience with Javascript. Hugs!