jquery – scrolls to the end of a div with OnClientClick = ""

I have the following code


in this case OnClientClick = "setDivscroll ()" I make a call to a jquery event and I create a div that is filled with data to position on the latest data. the problem is that the div is of different size with each click because it's a message div the event works fine but when i click twice
or if both div have the same height

This is my event at JQUERY

    setDivscroll () function
$ (# Message_box). scrollTop ($ (# message_box & # 39;)[0].scrollHeight);

If it serves here, my message box is in styles that have overflow-y: scroll; and a height: 500px;

User name
Alexander Herthic
<%# Eval("va_des_msj") %>
5 min ago

I think the problem arises because it first creates the event 'OnClientClick', then simply fills the data of the div, leaving scrollHeight with the value of the previous div before the up_pan_chat update that can hold more messages