1
I have a div chat-history
attribute-ridden overflow-y:scroll
.
Through jQuery I insert information into the database and then update to display in the div chat-history
. I need that when updating the div via Ajax request, it stay focused on the last line of the scroll bar.
Follows excerpt from the code that updates the div right after entering the data in the database.
function atualiza(){
$.get(''+ url +'/chat-history', function(result){
$('.chat-history').html(result);
})
setTimeout('atualiza()', 3000);
$('#message-to-send').val('');
$('#sendMessage').attr("disabled", false);
//neste momento a div chat-history que está com scroll deve ter seu foco na última linha
}
I tried to
$('html, body').animate({ scrollTop: $('.chat-history').offset().bottom }, 300);
But I didn’t get the expected result
Well, if the scroll is on . chat-history, you should call the Animate in it. You can post the code so that we can suggest something to you more accurately?
– LF Ziron