当前位置: 代码迷 >> Web前端 >> 关于div跟textarea的自动scroll
  详细解决方案

关于div跟textarea的自动scroll

热度:192   发布时间:2012-11-23 22:54:33.0
关于div和textarea的自动scroll
1, div
<div style="width:100%; height:95%; overflow-y:scroll">
<div id="command_result" style="height:90%; width:100%"></div>
<div id="command_result_end" style="overflow:hidden; height:1px"></div>
</div>
<script>
document.getElementById("command_result_end").scrollIntoView();
</script>

2, textarea
var obj = document.getElementById("command_result");
obj.scrollTop=obj.scrollHeight
  相关解决方案