获取具有溢出的div的高度:auto;

我有一个高度为div:100px和overflow:auto内容是动态的。

我想滚动底部的div

我试过了

$("#chat_content").scrollTop($("#chat_content").height()); 

但是如果内容大于100px $(“#chat_content”)。height()返回100并且div不在底部滚动

我能怎么做?

谢谢

从底层DOM元素获取scrollHeight属性:

 $("#chat_content").scrollTop($("#chat_content").get(0).scrollHeight); 

尝试$("#chat_content").scrollTop($("#chat_content").get(0).scrollHeight);

另一种方法是将内部内容包装在div中,然后只需将“.height”调用更改为

 $("#chat_content").scrollTop($("#chat_content div").height());