2016-04-18 43 views
0

我有一個與聊天的div,這已經可以滾動。但我希望它自動滾動到上次聊天。 以下是加載時聊天框的外觀。 enter image description here我如何讓一個div滾動到其結尾,Y軸

但我想它像下面的圖像,當它加載。

enter image description here

我怎樣才能做到這一點?親切的幫助表示感謝,謝謝!

+0

重複的http://stackoverflow.com/a/15629743/4672534 – rmondesilva

回答

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

如果你試着去了解heightscrollheight值,公式爲:

Element.scrollTop = Element.scrollHeight - Element.offsetHeight; 

注:Element變量表示滾動容器元素。

相關問題