I'm working on a side navigation element which needs to change color based on which menu is selected. I'm trying to set the class of a parent div to match that of a li which is part of the menu. Here's the code:
<div class="cols" id="leftMenuWrapper">
<div id="leftmenu">
<ul id="navsub_657930_721861">
<li class="lmenu_item2"><a href="#">Benefits</a></li>
</ul>
</div>
</div>
In this example, I need to set the class of "leftmenu" to "lmenu_item2". I tried this jQuery but it didn't work.
$('#leftmenu').addClass($('#leftmenu ul li').class());
I'm assuming the issue is with .class in the code above. Not sure how to grab the class from the li.
Thanks in advance for any help!