:last Selector

last selector

version added: 1.0jQuery(':last')

描述: 选择最后一个匹配的元素。

注意:last选择一个过滤和匹配当前jQuery集合在它的最后一个单独的元素。

Example:

Finds the last table row.

<!DOCTYPE html>
<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
  <table>

    <tr><td>First Row</td></tr>
    <tr><td>Middle Row</td></tr>
    <tr><td>Last Row</td></tr>

  </table>
<script>$("tr:last").css({backgroundColor: 'yellow', fontWeight: 'bolder'});</script>

</body>
</html>

Demo:

jQuery 1.6 API 中文版Clove整理、修订