
-
AuthorPosts
-
November 28, 2018 at 11:10 am #1038412
I’ve built a page with a Fullwidth Sub Menu (Enfold 4.5), and the menu items are links to anchors in the content below, on the same page.
I’m able to style the submenu items on :hover, but how can I get the active menu item to be styled differently than the rest (different color and background-color), when the page is scrolled to that anchor point, whether by clicking on the submenu item or just by scrolling? Already tried the following, and no luck:
Add this in my function.php ://One page nav highlight function activateMenuItem(){ ?> <script> jQuery(document).scroll(function() { var sections = jQuery('.avia-section'), menu = jQuery('.av-submenu-container'), 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(); if (cur_pos >= top && cur_pos <= bottom) { menu.find('li.active-menu-item').toggleClass('active-menu-item'); menu.find('a[href="https://'+window.location.host+window.location.pathname+'#' + jQuery(this).attr('id') + '"]').parent("li").toggleClass('active-menu-item'); } }); }); }); </script> <?php } add_action('wp_head', 'activateMenuItem');
and also this CSS :
/* Fullwidth Sub Menu - Indicator */ .av-subnav-menu > li:hover { border-bottom: 2px solid #ed1c23; } .av-subnav-menu > li.active-menu-item { border-bottom: 2px solid #ed1c23; }
Thanks in advance.
November 28, 2018 at 12:45 pm #1038473Hey makue10,
Could you please give us a link to your website, we need more context to be able to help you.
Best regards,
VictoriaNovember 28, 2018 at 2:16 pm #1038517This reply has been marked as private.November 29, 2018 at 1:51 pm #1038952Hello again! I sent you a personal message with login and I wanted to make sure you saw it.
December 2, 2018 at 12:32 pm #1039896Hi,
Thank you for writing to us.
Let me share an example link which shows the submenu highlight feature in action.
To achieve this modification please refer to the documentation
Let us know if you need any help!
Best regards,
VinayDecember 3, 2018 at 9:57 am #1040196Thanks a lot for the help. My misunderstanding was the custom css class.
December 3, 2018 at 3:00 pm #1040331 -
AuthorPosts
- You must be logged in to reply to this topic.