How to get last item with jQuery

If you use jQuery in your projects you should know about the .last() function.

It allows you to play with the last item.

Example

Use it in a menu UL list to remove the last item border.

$('.menu li').last().css('border', 'none');

Takes the last LI from the element with the menu class .

More info about the .last() function in the oficial site.

About Rick

Senior Front-end Software Engineer from Barcelona, Haidong Gumdo Instructor (korean martial art of the sword), street photographer, travel lover, TV addict, Boston Red Sox fan, and privacy advocate.

Leave a Reply

Add <code> Some Code </code> by using this tags.

*
*