我有一个链接按钮转到另一个页面,它可以工作,但我希望链接转到该页面的一个特定部分。我知道我应该为此使用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 –