高さ:100pxとオーバーフロー:オートのdivがあり、コンテンツは動的です。
一番下のdivをスクロールしたい
私は試してみました
$("#chat_content").scrollTop($("#chat_content").height());
ただし、コンテンツが 100px より大きい場合 $("#chat_content").height() は 100 を返し、div は下部にスクロールされません
どのようにできるのか?
ありがとう
scrollHeight
基になる DOM 要素からプロパティを取得します。
$("#chat_content").scrollTop($("#chat_content").get(0).scrollHeight);
試す$("#chat_content").scrollTop($("#chat_content").get(0).scrollHeight);
もう1つの方法は、内部コンテンツをdivでラップしてから、「。height」呼び出しをに変更することです。
$("#chat_content").scrollTop($("#chat_content div").height());