JS让DIV的滚动条自动保持在底部
<script type="text/javascript"> function add() { var now = new Date(); var div = document.getElementById('scrolldIV'); div.innerHTML = div.innerHTML + 'time_' + now.getTime() + '<br />'; div.scrollTop = div.scrollHeight; } </script> <!--//插入最新信息,当出现滚动条时,滚动条将自动保持在底部。--> <div class="txa" id="scrolldIV" style="height:320px; overflow:scroll; overflow-x:hidden;"> </div>
参考: https://www.cnblogs.com/heibaiqi/p/16874064.html