add class to last 2 links from a generate ul list

marilynmango

New Member
I have a function that generates a unordered list of links and I want to use javascript to select the last 2 links so that I can align them to the right.so in the following example I would need to select the li parent of link4 and link5, then add a class so i can style it\[code\]<ul><li>link1</li><li>link2</li><li>link3</li><li>link4</li><li>link5</li></ul>\[/code\]In the end it should be something like this:\[code\]<ul><li>link1</li><li>link2</li><li>link3</li><li class="align_right">link4</li><li class="align_right">link5</li></ul>\[/code\]
 
Top