滚动回到可滚动div的顶部 [英] Scroll back to the top of scrollable div
本文介绍了滚动回到可滚动div的顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<div id="containerDiv"></div>
#containerDiv {
position: absolute;
top: 0px;
width: 400px;
height: 100%;
padding: 5px;
font-size: .875em;
overflow-y: scroll;
}
document.getElementById("containerDiv").innerHTML = variableLongText;
下次如何将滚动位置重置回容器div的顶部?
How to reset the scroll position back to top of container div the next time?
推荐答案
var myDiv = document.getElementById('containerDiv');
myDiv.innerHTML = variableLongText;
myDiv.scrollTop = 0;
请参见 scrollTop
属性.
这篇关于滚动回到可滚动div的顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文