【发布时间】:2016-05-05 11:50:53
【问题描述】:
我有一个链接按钮可以转到另一个页面,它可以工作,但我希望链接转到该页面的特定部分。我知道我应该为此使用 jquery,并且由于某种原因它没有跳转到我希望它跳转到的部分。
我的按钮链接:
<div class="btn_holder top-slide"><a
href="http://testurl.com/media#isabelo"><p class="leeu_button">READ
MORE</p></a>
</div>
我目前滚动到页面底部而不是 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
<div class="content_holder terms_row" id="isabelo">
【问题讨论】:
-
id="isabelo"是唯一的吗? -
关于 jquery... 看这里stackoverflow.com/questions/9652944/…
标签: javascript jquery html