English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
:last-of-type selector selects all elements that are the last child of their parent element of a specific type.
This is similar to the :nth-last-of-type(1)is the same.
Using:first-of-typeSelectors can choose all elements that are the first child of their parent element of a specific type.
$(":last-of-$("type")
Select each <p> element that is the last child of its parent element:
$("document").ready(function(){ $("p:last-of-type").css("background", "coral"); });Test See‹/›
Select all <div> elements containing the last <p> element:
$("document").ready(function(){ $("div p:last-of-type").css("background", "coral"); });Test See‹/›