jQuery :last-of-type Selector

Last Updated Jul 21, 2015, 12:00:06 PM

jQuery :last-of-type Selector

jQuery :last-of-type selector matches elements that have no other element with both the same parent and the same element name coming before it in the document tree.

It works similar to jQuery :first-of-type selector but the only difference is it selects the last element


When there are multiple elements with the same content or same value, jquery :last-of-type selector will select the last element of its type


It will find the last span in each matched div and add a class to it.

There are elements named Tom and Rupe three times. But it only selected the last of its type.

jQuery last-of-type selector

Try It Now

All jQuery Child Selectors

Other Advanced jQuery Selectors you might want to learn
jQuery Complete Selectors Reference

jQuery Selectors

jQuery Basic Selectors

jQuery Child Selectors

jQuery Content Filter Selectors

Sources and Credits

The content and methods in the tutorial has been referred and updated with jQuery API and The jQuery Foundation

Last Updated Jul 21, 2015, 12:00:06 PM