Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery :last Selector

jQuery :last Selector

jQuery selector jQuery selector

Example

Select the last

element:

$("p:last")

Try it »


Definition and Usage

The :last selector selects the last element.

**Note:** This selector only selects a single element. Use the :last-child selector to select multiple elements (one for each parent).

Most common usage: used together with other selectors to select the last element in a specified group (as in the example above).

**Tip:** To select the first element in a specified group, use the :first selector.


Syntax

$(":last")


Try it - Example

Difference between :last and :last-child
Demonstrate the difference between the :last and :last-child selectors.


jQuery selector jQuery selector