I am using jQuery scrollTop() to navigate within a page.
Since I have sticky navigation, I tried offset() so that the element isn't behind the nav but it's not working 100%.
This is my code (adopted from this thread):
<a href="#personal-history" class="sliding-link">Personal History</a>
$(".sliding-link").click(function(e) {
e.preventDefault();
var aid = $(this).attr("href");
$('html,body').animate({scrollTop: $(aid).offset().top - 100},'slow');
});
What's missing?
Update - Here's the code for my sticky menu (it is 60px high) -
<nav id="sticky-navigation" class="has-sticky-branding" itemtype="https://schema.org/SiteNavigationElement" itemscope="" style="z-index: 100; display: block; margin-top: 32px; position: fixed; top: 0px; width: 731px;">
<div class="inside-navigation">
<div class="navigation-branding">
<div class="sticky-navigation-logo">
<a href="#"><img src="#"></a>
</div>
</div>
<button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false"><span class="mobile-menu">Menu</span></button>
<div id="primary-menu" class="main-nav">
<ul id="menu-main" class=" menu sf-menu">
<li id="menu-item-32" class="home menu-item menu-item-type-post_type menu-item-object-page menu-item-home current-menu-item page_item page-item-2 current_page_item menu-item-32"><a href="#" aria-current="page" class="sliding-link">Home</a></li >
</ul>
</div>
</div>
</nav>