Hi,
How can I add class to a list and the sub-list...? I have tried the code below but it wont work...
Code:
$(document).ready(function(){
$("#menu li:last").addClass('last');
$("#menu li li:last").addClass('sublast');
});
this is the html code which i add the class 'last' and 'sublast' manually... the ideal situation i wish to achieve is to add these classes through jquery...
is it possible??
Code:
<div id="menu">
<ul>
<li><a href="#">NEWS</a>
<ul>
<li><a href="#">News</a></li>
<li><a href="#">Opportunities</a></li>
<li class="sublast"><a href="#">Newsletters</a></li>
</ul>
</li>
<li><a href="#">WORK</a>
<ul>
<li><a href="#">Past</a></li>
<li><a href="#">Present</a></li>
<li class="sublast"><a href="#">Future</a></li>
</ul>
</li>
<li class="last"><a href="#">US</a>
<ul>
<li><a href="#">About us</a></li>
<li><a href="#">People</a></li>
<li class="sublast"><a href="#">Support</a></li>
</ul>
</li>
</ul>
</div>
many thanks,
Lau