I have menu and I want to add css class to menu item based on current url
I try to use jQuery but this code add current-active-menu css class only to a href="https://mywebsite.com/dashboard/ element
jQuery(document).ready(function() {
if (window.location.href.indexOf("https://mywebsite.com/dashboard/") > -1) {
$('a[href="https://mywebsite.com/dashboard/"]').addClass("current-active-menu");
}
});
jQuery(document).ready(function() {
if (window.location.href.indexOf("https://mywebsite.com/dashboard/?candidate-page=resumes-list") > -1) {
$('a[href="https://mywebsite.com/dashboard/?candidate-page=resumes-list"]').addClass("current-active-menu");
}
});
jQuery(document).ready(function() {
if (window.location.href.indexOf("https://mywebsite.com/dashboard/?candidate-page=my-orders") > -1) {
$('a[href="https://mywebsite.com/dashboard/?candidate-page=my-orders"]').addClass("current-active-menu");
}
});