# :last Selector

Categories: Selectors > Basic Filter | Selectors > jQuery Extensions

## last selector

#### version added: 1.0jQuery(':last')

Description: Selects the last matched element.

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

### Additional Notes:

- Because `:last` is a jQuery extension and not part of the CSS specification, queries using `:last` cannot take advantage of the performance boost provided by the native DOM `querySelectorAll()` method. To achieve the best performance when using `:last` to select elements, first select the elements using a pure CSS selector, then use `.filter(":last")`.

### Example:

#### Finds the last table row.

    <!DOCTYPE html>
    <html>
    <head>
      <script src="http://code.jquery.com/jquery-1.7rc2.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: