I want to add a class to a menuepoint if one path is selected.
It would be easy if every site was its own .php/.html file, however everything is ruled in one .php file and everything is navigated over actions (?action=main, ?action=userinformation).
I am searching for an alternative to get this work with the path and the action.
if (location.pathname == "/index.php") {
$("#main1").addClass("mainActive");
} else if (location.pathname == "/index.php?action=other") {
$("#main2").addClass("mainActive");
}
location.pathnamedoesn’t include the query string. But you can combine it withlocation.search: