I have been trying to troubleshoot the problem but I can't find what's wrong. I simply want to scroll to a <section>
element with a specific ID whenever a link is clicked. There are many sections on the page. But somehow every time any of the link is clicked the page scrolls to the first section and not the correct one.
Here is the HTML :
<ul class="menu fsMed lightFont horizontal" id="peopleMenu">
<li><a class="currentColor" href="#pageIntroHead">All</a></li>
<li><a class="currentColor" href="#principle_associates">Principle Associates</a></li>
<li><a class="currentColor" href="#executive_associates">Executive Associates</a></li>
<li><a class="currentColor" href="#senior_associates">Senior Associates</a></li>
<li><a class="currentColor" href="#associates">Associates</a></li>
</ul>
Here is the JQuery code:
jQuery(document).ready(function($) {
jQuery('#peopleMenu li a').click(function(e) {
e.preventDefault();
console.log(jQuery(this).attr('href'));
jQuery('html, body').animate({
scrollTop: jQuery( jQuery.attr(this, 'href') ).offset().top
}, 500);
return false;
});
});
I guess the problem isn't with JQuery code but something conflicts with it. Here is the URL depicting the problem : http://jla.ma-digital.net/team-structure/
At top right you see the links Executive Associates etc.
Any Help would be Appreciated.
Thanks