Finding the Last Element
Many times you want to find the last element of something. Obviously there are many different ways to find that element.
Last Element of an array: PHP
For example you can find the last element of an array with PHP using the end() function.
The Last DOM element with JQuery
You can also find the last DOM element using JQuery. This is handy for finding things like the last <li> or the last <div>. You can find the last item in JQuery using .last()
$( "li" ).last().css( "background-color", "red" );
Last element in CSS
You can use structural pseudo-classes in CSS to advance selectors allowing you to target specific elements based on their position in the document hierarchy. In the CSS you can choose the HTML element you want to add a psuedo-class to. To select the last element use “:last-child”. This is a CSS3 specification so it might not work in all browsers. Here is an example.