ドキュメント

Selectors/last

From jQuery JavaScript Library

Jump to: navigation, search

« Back to Selectors

:last

Matches the last selected element.
Examples:

Finds the last table row.

$("tr:last").css({backgroundColor: 'yellow', fontWeight: 'bolder'});

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                    "http://www.w3.org/TR/html4/loose.dtd">
<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>

NameType