Reputation: 131
I have this bootstrap-accordion code inside a Wordpress Theme:
<ul id="menu-main-menu-horizontal-1" class="mobile-menu accordion-menu">
<li id="accordion-menu-item-1906" class="menu-item menu-item-type-taxonomy menu-item-object-product_cat menu-item-has-children has-sub">
<a class="nolink" href="#">CLICK ME</a><span class="arrow"></span>
<ul class="sub-menu">
<li id="accordion-menu-item-1922" class="menu-item menu-item-type-taxonomy menu-item-object-product_cat"><a href="/one" class="">ONE</a></li>
<li id="accordion-menu-item-1904" class="menu-item menu-item-type-taxonomy menu-item-object-product_cat"><a href="/two" class="">TWO</a></li>
</ul>
</ul>
When i click on the ARROW, the submenu opens and closes correctly, collapsing and expanding and so on.
Now, i want to make it happen the same thing, when i click on the anchor link "CLICK ME". I want the submenu to open and close like when i click on the arrow.
Which data-attributes / class, must I attach to that link to 'activate' it and command the sub-menu ?
Please help, i'm stuck with it.
Upvotes: 0
Views: 461
Reputation: 395
You can use the below jQuery code to toggle the menu on click of click me.
$('.nolink').click(function() {
$('.sub-menu').toggle();
});
Upvotes: 2