Make a Div scroll to bottom

Make a Div scroll to bottom

  

I'm trying to make a div with Chat Messages scroll to the last message when we add the last message on the table with those messages to be displayed.

Can someone help me?

I already tried with javascript, but it is not recognizing the div to make something like this:

var element = document.getElementById("yourDivID");
    element.scrollTop = element.scrollHeight;

what do you mean it's not recognizing the div?


do you create the javascript via an expression?

then it would be something like: 

"

var element = document.getElementById('#" + yourDiv.Id + "');

element.scrollTop = element.scrollHeight;

"

J. wrote:

what do you mean it's not recognizing the div?


do you create the javascript via an expression?

then it would be something like: 

"

var element = document.getElementById('#" + yourDiv.Id + "');

element.scrollTop = element.scrollHeight;

"

Yeah J i want that exactly, im already using that piece of code, but it seems that the "element.scrollTop = element.scrollHeight;" isn't doing anything....

That worked with you?


not sure,

try using the jquery variant:

$('#div1').scrollTop($('#div1')[0].scrollHeight);

otherwise provide a live demo so we can check what might go wrong (aka personalcloud example)