Apply Style on parent acnhor tag for each li
I want to apply style using jQuery on the last anchor tag of each li where there is no item for that anchor so that it's foreground color should be red,here below i've hard coded values so every one can understand the scenario,so for eg:if Cat1 anchor had no item then it's color should be red similarly if Subcat1 anchor had no item then it's foreground color should be red and so on.
<ul class="nav"> <li class="mainparent"> <a href="#">Main Category</a> <ul> <li> <a href="#">Cat1</a> <ul> <li><a href="#">Subcat1</a> <ul> <li><a href="#">Sub Subcat1</a></li> <li><a href="#">Sub Subcat2</a></li> <li><a href="#">Sub Subcat3</a></li> </ul> </li> <li><a href="#">Subcat2</a></li> <li><a href="#">Subcat3</a></li> <li><a href="#">Subcat4</a></li> <li><a href="#">Subcat5</a></li> <li><a href="#">Subcat6</a></li> </ul> </li> </ul> </li>
</ul>