How to select first and last LI in every UL?
I have a nested system of UL's to create a multi-level dropdown menu.
I am trying to add classes ".first" and ".last" to the first and last LI in every UL, no matter what level in the menu.
Current I have tried...
-
$("#mainnav li ul li:first").addClass("first");
$("#mainnav li ul li:last").addClass("last");
But, this pulls a result of ALL LI's in every UL, so only the first LI in the first UL is styled, and the last LI in the last UL.
How do I make it style the first and last LI in EVERY UL?
THANKS!