I have set a custom id for my element. When I attempt to link to the anchor it shows up behind the fixed header menu. I searched the forum and found various other topics addressing this issue. But none of the javascript code snippets seem to work for me. This is not a one-page website. This was the most recent code I tried using.
jQuery(document).ready(function ($){
$('a[href*="#"]').off( "click touchstart");
$('a[href*="#"]').on('touchend click', function(e) {
href = $(this).attr('href');
notComments = href.indexOf('#comments') === -1;
if ( href !== '#' && notComments ) {
var theId = href.split('#').pop();
var $el = $('#' + theId);
if ( $el.length > 0 ) {
e.preventDefault();
$('html, body').animate({
scrollTop: $($el).offset().top -58
}, 450);
return false;
}
}
});
});