- 利用
<a>
标签的锚点
<h3 name="top">唐诗300首</h3>
<a href="#top">顶部</a>
//点击顶部可以跳转到唐诗300首
- 利用
location.href
<p id="ddd">底部</p>
<button onclick="gobuttom()">底部</button>
function goButtom() {
location.href = "#ddd";
}
<a>
标签的锚点<h3 name="top">唐诗300首</h3>
<a href="#top">顶部</a>
//点击顶部可以跳转到唐诗300首
location.href
<p id="ddd">底部</p>
<button onclick="gobuttom()">底部</button>
function goButtom() {
location.href = "#ddd";
}