I am able to change the CSS when I clicked on a title to expand a menu. However other ‘header’ which has been expanded are unable to change to “inactive” class.
Below is my HTML
<dt class="productsCat"><a href="/" class="productsName">Category 1</a></dt>
<dd class="subCat"><a href="<?php echo $subCategory->getUrl()?>">Sub Category 1</a></dd>
<dt class="productsCat"><a href="/" class="productsName">Category 2</a></dt>
<dd class="subCat"><a href="<?php echo $subCategory->getUrl()?>">Sub Category 2</a></dd>
And here is my jQuery
jQuery(document).ready(function(){
jQuery("dl#narrow-by-list> dd:not(:first)").hide();
jQuery("dl#narrow-by-list> dt a").click(function(){
jQuery("dl#narrow-by-list> dd:visible").slideUp("fast");
jQuery(this).parent().next().slideDown("fast");
jQuery(this).parent().removeClass("productsCat");
jQuery(this).parent().addClass("openSub");
return false;
});
});
Any advice how I should remove the class “openSub” and use the existing class “productsCat” from all the other siblings when one is active?
Thank you!
So, try this, works in my local..