get height for a div with overflow:auto;

前端 未结 3 1209
囚心锁ツ
囚心锁ツ 2021-02-13 06:12

i have a div with height:100px and overflow:auto the content is dynamic.

i want scroll the div in the bottom

i tried with

$(\"#chat_content\").sc         


        
相关标签:
3条回答
  • 2021-02-13 06:27

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

    0 讨论(0)
  • 2021-02-13 06:28

    Another way is to just wrap the internal content in a div and then just change your ".height" call to

    $("#chat_content").scrollTop($("#chat_content div").height());
    
    0 讨论(0)
  • 2021-02-13 06:31

    Get the scrollHeight property from the underlying DOM element:

    $("#chat_content").scrollTop($("#chat_content").get(0).scrollHeight);
    
    0 讨论(0)
提交回复
热议问题