I have a menu with submenu with a structure like this:
<ul>
<li>
<a class="navigation-item">Menu Item 1</a>
<a class="submenu-toggle" />
<ul class="submenu">
<li>
<a class="navigation-item">Submenu Item 1</a>
</li>
</ul>
</li>
</ul>
I want to add a class to submenu-toggle if Submenu Item 1 is selected. How can I find the submenu-toggle in this case?
closest('li')
won’ work, this will only find the li after the submenu. closest('li > .submenu-toggle')
doesn’t work either because the .submenu-toggle
has to be an ancestor of the submenu item. If I could select the correct li, I could then use find('.submenu-toggle')
. But how do I select the correct li?
You need to sign in to view this answers