錨鏈接(`` + `href="#..."`)雖能快速定位長頁面內容(如 FAQ),但瞬間跳轉易讓用戶迷失:內容「跑哪去了?」缺乏空間位移感知。
構建字母順序索引導航,點擊觸發平滑滾動動畫至目標錨點,保持空間連續性,兼容 IE6+。

<nav id="links">
<ul class="clearfix">
<li class="label">快速鏈接:</li>
<li><a href="#indexa">A</a></li>
<li><a href="#indexb">B</a></li>
...
<li><a href="#indexg">G</a></li>
</ul>
</nav>
<!-- 目標錨點區塊 -->
<a name="indexb"></a>
<div class="show">...內容...</div>
.show { display: block; padding-top: 8px; margin-bottom: 23px; }
.meta { float: right; font: bold 0.8em Arial, Verdana, sans-serif; color: #222; }
$(document).ready(function() {
$('#links > ul > li > a').on('click', function(e) {
e.preventDefault(); // 阻止默認跳轉與 URL hash 變更
var anchorId = $(this.hash);
// 兼容舊式 name 錨點
if (anchorId.length === 0) {
anchorId = $('a[name="' + this.hash.substr(1) + '"]');
}
// 平滑滾動動畫 450ms
$('html, body').animate({ scrollTop: anchorId.offset().top }, 450);
});
});

適用於:FAQ 頁面、長文檔檔、產品規格對照表、字母排序目錄等長內容頁面。優雅滾動替代生硬跳轉,顯著提升用戶空間定向感與閱讀連續性。
文章來源:夢想天空