Hi Guys,
I’m trying to highlight the selected navigation item based on links within the same page.
Menu items are anchor links defined by ID and I’m displaying them using the Navigation Menu widget.
Hope you can help.
Cheers,
Claire : )
Hi Guys,
I’m trying to highlight the selected navigation item based on links within the same page.
Menu items are anchor links defined by ID and I’m displaying them using the Navigation Menu widget.
Hope you can help.
Cheers,
Claire : )
Hi Claire,
Thanks for writing in!
Can you provide us the url of the page where we can see the Navigation Menu Widget
and the links you are referring to.
Thanks
Hi Paul,
Just responded via secure note.
Thanks again in advance for your swift response.
Claire
Hi Claire,
Please add this code under X > Theme Options > JS:
jQuery(document).ready(function($) {
$("#menu-latest-greatest li a").on('click', function(event) {
event.preventDefault();
$("#menu-latest-greatest li a").removeClass('x-menu-active');
$(this).addClass('x-menu-active');
});
});
After that add this custom CSS under X > Theme Options > CSS:
#menu-latest-greatest li a.x-menu-active {
color: red;
}
Let us know how it goes!
Thanks superstars - this worked perfectly!
Hi again : )
Is there a way to make the h-widget title of the active menu item highlight too?
Hi there,
Please change the Javascript code to:
(function( $ ) {
$(function() {
$("#menu-latest-greatest li a").on('click', function(event) {
event.preventDefault();
$("#menu-latest-greatest li a").removeClass('x-menu-active');
$(this).addClass('x-menu-active');
$('.widget .h-widget').removeClass('x-menu-active');
$(this).closest('.widget').find('.h-widget').addClass('x-menu-active');
});
});
})(jQuery);
and the CSS code to:
#menu-latest-greatest li a.x-menu-active,
.h-widget.x-menu-active {
color: #28b46e;
}
Hope it helps.
Thanks a million superstars! Once again, your support service proves to be THE BEST!
You’re most welcome.
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.