Persistent highlighting of the menu

Hi guys,

new member, sorry if my question is in the wrong place or in the wrong format.

I have a "primary" menu that leads to a "secondary" menu and I highlight it as follows:

jQuery (document) .ready (function ($) {

$ ("a"). each (function () {
if ((window.location.pathname.indexOf ($ (this) .attr (& # 39; href & # 39;)))> -1) {
$ (this) .addClass (& # 39; activeMenuItem & # 39;);

and so css:

a.activeMenuItem {
background color: white;
font weight: bold;

It works fine, but when a user selects an item in the "secondary" menu, the highlight is lost in the "main" menu. Is there a way to keep highlighting in the "main" menu?

Thank you and hello to all members of the community!