0
jQueryを同じページと別のページにアニメーション化します。ホームページ弊社についてでjqueryを同じページと別のページにアニメ化する
var jump=function(e)
{
if (e){
var $height = -100;
e.preventDefault();
var target = $(this).attr("href");
}else{
var $height = 300;
var target = location.hash;
}
$('html, body').animate({
scrollTop: $(target).offset().top + $height
},1500,function()
{
location.hash = target;
});
}
$(document).ready(function(e) {
$('.navbar-nav .menu-item-type-custom a[href^=#], .offer-sidebar .menu-item-type-custom a[href^=#]').bind("click", jump);
if (location.hash){
setTimeout(function(){
window.scrollTo(0, 0);
$('html, body').scrollTop(0).show()
jump()
}, 1);
}
});
<div class="nav">
<a href="http://www.exmaple.com/"> Home </a>
<a href="http://www.exmaple.com/contact"> Contact </a>
<a href="#footer"> Footer </a> // working fine
<a href="http://www.exmaple.com/#aboutus"> About us </a> // Not work
</div>
は(動作していない)と連絡先のページでは、それが働いて、私たちについて、同じページ上のセクションをスクロールダウンし、私達についてのセクションにホームページスクロールにジャンプします。 誰かが同じページと別のページで完全なURLを扱うことができますか?アンカー名の前に必要な/
の必要がない
/' Footerが'の必要なしで、後でそれを参照してください。 // will will work –
私の質問を編集してください。 –