点击跳转到顶部
第一种最简单的方式
<span class="bottom-bar-item"><a href="#">↑</a></span>
第二种
<span class="bottom-bar-item"><a href="javascript:void(0)" onclick="goTop()">↑</a></span>
<script>
function goTop() {
$('html, body').animate({scrollTop:0}, 'slow');
}
</script>
点击跳转到底部
<span class="bottom-bar-item"><a href="javascript:void(0)" onclick="goBottom()">↓</a></span>
<script>
function goBottom() {
window.scrollTo(0, document.documentElement.scrollHeight-document.documentElement.clientHeight);
}
</script>

本文介绍两种实现网页内部跳转的方法,一种是通过简单的HTML链接,另一种是使用JavaScript函数实现平滑滚动到页面顶部或底部。这些技巧对于提升用户体验非常有用。
1097

被折叠的 条评论
为什么被折叠?



