jQuery :lastSelector

jQuery 选择器jQuery Selectors

Examples

Select the last <p> element:

$("p:last")

Try it Yourself »

Definition and Usage

The :last selector selects the last element.

Note:This selector is only used to select a single element. Use:last-childselector to select multiple elements (one for each parent element).

The most common usage: use it together with other selectors to select the last element in a specified combination (as in the example above).

Tip:To select the first element in a specified combination, use:firstthe selector.


Syntax

$(":last")


实例

Try it Yourself - Examples

The difference between :last and :last-child
Demonstrates the difference between the :last and :last-child selectors.


jQuery 选择器jQuery Selectors

Other Extensions