我有一個鏈接按鈕轉到另一個頁面,它可以工作,但我希望鏈接轉到該頁面的一個特定部分。我知道我應該爲此使用jquery,由於某種原因,它不跳轉到我希望它跳到的部分。將一個按鈕鏈接到另一個頁面的一部分
我的按鈕鏈接:
<div class="btn_holder top-slide"><a
href="http://testurl.com/media#isabelo"><p class="leeu_button">READ
MORE</p></a>
</div>
我目前有srolls到頁面底部,而不是部分其中id =「isabelo」。所以這jQuery的作品,但它不是我想要的。希望你能理解。
$(document).ready(function(){
//check if hash tag exists in the URL
if(window.location.hash) {
$("html, body").animate({ scrollTop: $(document).height() }, 1000);
1000);
} });
我也已經嘗試過這種(不工作):
$(document).ready(function(){
//check if hash tag exists in the URL
if(window.location.hash) {
$('html, body').animate({ scrollTop: $("#isabelo").offset().top }, 1000);
}
});
的頁面即時試圖鏈接到與一個ID = 「isabelo」
<div class="content_holder terms_row" id="isabelo">
is'id =「isabelo」'unique? – BenG
關於jquery ... 看這裏http://stackoverflow.com/questions/9652944/jquery-scroll-to-id-from-different-page –