相关疑难解决方法(0)

滚动回到div的顶部

<div id="containerDiv"></div>
Run Code Online (Sandbox Code Playgroud)
#containerDiv {
  position: absolute;
  top: 0px;
  width: 400px;
  height: 100%;
  padding: 5px;
  font-size: .875em;
  overflow-y: scroll;
}
Run Code Online (Sandbox Code Playgroud)
document.getElementById("containerDiv").innerHTML = variableLongText;
Run Code Online (Sandbox Code Playgroud)

如何在下次将滚动位置重置回容器div的顶部?

html javascript scroll

97
推荐指数
9
解决办法
18万
查看次数

标签 统计

html ×1

javascript ×1

scroll ×1