我有这段代码
<div style="width: 400px; height:200px; background-color: #090; overflow-y: scroll">
<p>first</p>
<p>aaaaaaaaaa</p>
<p>aaaaaaaaaa</p>
<p>aaaaaaaaaa</p>
<p>aaaaaaaaaa</p>
<p>aaaaaaaaaa</p>
<p>aaaaaaaaaa</p>
<p>aaaaaaaaaa</p>
<p>aaaaaaaaaa</p>
<p>last</p>
</div>
我需要点击一些元素,自动滚动底部(最大底部),即点击某个元素,需要这个结果:please see screenshot
请告诉我该怎么做?
答案 0 :(得分:2)
使用<p id="last">last</p>
和<a href="#last">Go to #last</a>
:
<div style="width: 400px; height:200px; background-color: #090; overflow-y: scroll">
<p>first - <a href="#last">Go to #last</a></p>
<p>aaaaaaaaaa</p>
<p>aaaaaaaaaa</p>
<p>aaaaaaaaaa</p>
<p>aaaaaaaaaa</p>
<p>aaaaaaaaaa</p>
<p>aaaaaaaaaa</p>
<p>aaaaaaaaaa</p>
<p>aaaaaaaaaa</p>
<p>aaaaaaaaaa</p>
<p>aaaaaaaaaa</p>
<p>aaaaaaaaaa</p>
<p>aaaaaaaaaa</p>
<p>aaaaaaaaaa</p>
<p>aaaaaaaaaa</p>
<p>aaaaaaaaaa</p>
<p>aaaaaaaaaa</p>
<p id="last">last</p>
</div>