Açıklama : Ebeveyninin son çocuğu olan elemanları bulur.
jQuery( ":last-child" )
Eklendiği Versiyon 1.1.4
Metod .last()
sadece bir tek eleman seçerken
:last-child
seçicisi her ebeveyn elemanın son çocuğundan oluşan bir set
döner.
Örnekler:
Her <div>
'deki son <span>
elemanını bulup stil ver
ve hover etkisi ver.
<style>
span.solast {
text-decoration: line-through;
}
</style>
<div>
<span>John,</span><span>Karl,</span><span>Brandon</span>
</div>
<div>
<span>Glen,</span><span>Tane,</span><span>Ralph</span>
</div>
<script>
$( "div span:last-child" )
.css({ color:"red", fontSize:"80%" })
.hover(function() {
$( this ).addClass( "solast" );
}, function() {
$( this ).removeClass( "solast" );
});
</script>
John,Karl,Brandon
Glen,Tane,Ralph