'Add class if (hidden) anchor is
I'm writing a function to add a class to different menu items on several conditions. The first condition is already working great but now I have something different.
I have a page with some tabs #tab1,#tab2 and #tab3. However the anchor is invisible in the URL even if I switch between the tabs.
My current function:
jQuery(document).ready(function($) {
if(window.location.pathname.indexOf("/konto/adressen/") !==-1) {
$(".jet-custom-nav__item-6068").addClass("current-menu-item");
}
else if(window.location.hash == "tab1") {
$(".jet-custom-nav__item-9886").addClass("current-menu-item");
}
});
The default tab page refresh is #tab1. After refresh the class is added to the right menu item but somehow my code makes the URL anchor visible and if I switch to another tab it stays still active. I would appreciate any help with this not too many experience by now!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
