I'm trying to add class '.open' to the parent li for the children with class .showme I've tried several things so far (prev, prevAll, has etc) but I can't get it right.
This is my html structure and also a jsFiddle to work on. Any suggestions will be appreciated.
<ul class="product-categories">
<li class="sub">
<a href="#">Women</a>
<ul>
<li class=""> <a href="#">Clothing</a></li>
<li class="showme"> <a href="#">Footwear</a></li>
</ul>
</li>
<li class="no-sub"> <a href="#">Men</a></li>
<li class="no-sub"> <a href="#">Children</a></li>
<li class="offers"> <a href="#">Offers</a></li>
</ul>
$(".showme").prevAll("li.sub:first").addClass("open")