:lastS2C Home « Selectors « :last

Last element match selector.

Shorthand version $(':last')

Description

The :last selector, selects the last matched element.

Being a jQuery extension the :last pseudo selector is not part of any current CSS specification. Therefore :last cannot take advantage of the performance boost provided by the native DOM querySelectorAll() method.

Syntax


Signature Description
jQuery(':last')Last element match

Parameters

None.

Return

N/A.

:last Examplego to top of page Top

Selects last matched element.

In the example below we apply an orange background to last 'td' element of the tables marked with a class of 'javatable'. So the table below will be selected but the Syntax table above will not.

Last Element Selector
Table Row 1, Table Data 1 Table Row 1, Table Data 2
Table Row 2, Table Data 1 Table Row 2, Table Data 2
Table Row 3, Table Data 1 Table Row 3, Table Data 2
Table Row 4, Table Data 1 Table Row 4, Table Data 2


$(function(){
  $('#btn19').on('click', function() {
    $(".jskeywordtable td:last").css('backgroundColor', 'orange');
  });
});

Press the button below to action the above code:


go to home page Homepage go to top of page Top