Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- The topic ‘Full Width Submenu active state’ is closed to new replies.
Hi, last week your great support team helped me figure out an issue with the Full Width Submenu active state on this page: http://staging.loopcreative.co/redseal/product/ and it works great (here is a link to the thread: here. I need to do this same thing on another page: http://staging.loopcreative.co/redseal/news/ but I must have done something wrong.
All I did to the original code was add #menu-news_submenu
a couple of lines down in the script as you can see.
Here is the full script in the function.php file (only added the new submenu “News_Submenu”):
`function activateMenuItem(){
?>
<script>
jQuery(document).scroll(function() {
var sections = jQuery(‘.one-page-nav’),
menu = jQuery(‘#menu-product_submenu,#menu-news_submenu’),
nav_height = menu.outerHeight();
jQuery(window).on(‘scroll’, function() {
var cur_pos = jQuery(this).scrollTop();
sections.each(function() {
var top = jQuery(this).offset().top – 300,
bottom = top + jQuery(this).outerHeight();
console.log(‘top is : ‘+ top);
console.log(‘bottom is : ‘+ bottom);
if (cur_pos >= top && cur_pos <= bottom) {
menu.find(‘li’).removeClass(‘active-menu-item’);
menu.find(‘a[href=”#’ + jQuery(this).attr(‘id’) + ‘”]’).closest(‘li’).addClass(‘active-menu-item’);
}
});
});
});
</script>
<?php
}
add_action(‘wp_head’, ‘activateMenuItem’);`
I will need to do this same thing on a couple of other pages as well.
Thanks for your help.
Slade
Sorry….I figured it out. You can close this thread.