Hey there,
I use the following JS to change the menu background color from transparent to white and the menu text from white to black:
jQuery(function($) {
$(window).scroll(function() {
if ($(window).scrollTop() > 400) {
$('.x-navbar').addClass("x-navbar-solid");
$('.x-navbar a').css("color", "#000");
$('.x-brand img').attr('src','https://elmar-rassi.com/wp-content/uploads/ER-logo-black.svg');
$('.mobile').css("background-color", "transparent");
} else {
$('.x-navbar').removeClass("x-navbar-solid");
$('.x-navbar a').css("color", "#fff");
$('.x-brand img').attr('src','https://elmar-rassi.com/wp-content/uploads/ER-logo-white.svg');
$('.mobile').css("background-color", "rgba(0,0,0,0.95)");
}
});
});
The CSS code of the added classes:
.x-navbar-wrap {
height: auto !important;
}
.x-navbar {
background-color:transparent;
border:0;
box-shadow:none;
position: fixed;
width:100%;
}
.x-navbar-solid {
background-color:rgba(255, 255, 255, 0.95);
transition: background-color 0.5s ease;
}
The challenge
The sub menu items are affected by the color change as well. I don’t want the sub menu items be affected by this color change, but the rest of the navigation. Please find the attached short video.
How can I specify that the color change in x.navbar a is not affecting the sub menu items?
Link to site + further infos in the private note.
Thank you.
Best
Adrian