腳本塊添加id
,得出:jQuery的跳躍ID(不包括動畫)
<div id="some">Text</div>
之後頁面應該跳轉爲id
,沒有動畫,就像我們的目標#some
上當前頁面鏈接。
如何做到這一點?
謝謝。
腳本塊添加id
,得出:jQuery的跳躍ID(不包括動畫)
<div id="some">Text</div>
之後頁面應該跳轉爲id
,沒有動畫,就像我們的目標#some
上當前頁面鏈接。
如何做到這一點?
謝謝。
你僅僅意味着連接 「老派」 像#some
例如
<a href="#some"></a>
完成在JS與
location.href = "#some";
像這樣:
location.href = "#some";
試試這個:
document.getElementById('some').scrollIntoView(true);
$('a[href^="#"]').click(function() {
$('html,body').animate({ scrollTop: $(this.hash).offset().top});
return false;
e.preventDefault();
});
+1因爲我從來沒有聽說過這個!驚訝它跨瀏覽器,儘管不屬於規範的一部分。 http://www.quirksmode.org/dom/w3c_cssom.html#t23 – Andrew 2010-06-11 14:51:35