English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

jQuery :last-Seletores child

Seletores jQuer

:last-Seletores child para escolher o último filho de um elemento pai.

Usar:first-childSeletores para escolher o primeiro filho de um elemento pai.

Sintaxe:

$(":last-child)

Exemplo

Escolher cada <p> que é o último filho de seu pai:

$(document).ready(function(){
  $("p:last-child").css("background", "coral");
});
Testar e Verificar‹/›

Escolher todos os elementos <div> que contêm o último <p>:

$(document).ready(function(){
  $("div p:last-child").css("background", "coral");
});
Testar e Verificar‹/›

Seletores jQuer