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