I'm using Slicknav on my site to add in a mobile friendly menu. I have a script I'm running to add smooth scrolling to page anchors, for some reason it works for child menu items but not parent menu items.
I'm guessing this is because the parent menu item has some sort of click function attached to it to open the child menu. I'm not great with jQuery and I'm not sure how to get around this.
Here's what I'm using to add the scrolling effect:
$('.slicknav_menu a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
&& location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').stop().animate({
scrollTop: target.offset().top - 120 //offsets for fixed header
}, 1000);
return false;
}
}
});