tadam logo
Did you find an error in the text?
Select this with mouse and press
Ctrl + Enter
Xhtml.co.il Check Spelling
Orphus system

last selector

Description: Selects the last matched element.

jQuery(':last')

version added: 1.0

Note that :last selects a single element by filtering the current jQuery collection and matching the last element within it.

Examples

Finds the last table row.
$("tr:last").css({backgroundColor: 'yellow', fontWeight: 'bolder'});
The output of the code above will be:
Full source:
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>  
  <script>
  $(document).ready(function(){
$("tr:last").css({backgroundColor: 'yellow', fontWeight: 'bolder'});
  });
  </script>
</head>
<body>
  <table>
    <tr><td>First Row</td></tr>
    <tr><td>Middle Row</td></tr>
    <tr><td>Last Row</td></tr>
  </table>
</body>
</html>
Was this information helpful?
   

Comments