.last()
** DEPRECATED **S2C Home « Filtering « .last()
Filter last element.
Description
The .last()
method is used to reduce the matched set to the last element.
This method was deprecated in jQuery 3.4.
Syntax
Signature | Description |
---|---|
.last() | Reduce the matched set to the last element. |
Parameters
None
Return
A jQuery
object containing the last element of the matched set.
.last()
ExampleTop
Reduce the matched set to the last element.
In the example below we select all 'td' elements within the table with the class of 'testtable' and then reduce the matched set to the last element.
Table Row 1, Table Data 1 | Table Row 1, Table Data 2 |
Table Row 2, Table Data 1 | Table Row 2, Table Data 2 |
$(function(){
$('#btn2').on('click', function() {
$('.testtable td').last()
.css('backgroundColor', 'orange');
});
});
Related Tutorials
jQuery Intermediate Tutorials - Lesson 1 - Filtering Elements