jQuery :last-of-typeSelector

jQuery 选择器jQuery Selector

Example

Select every <p> element that is the last <p> element of its parent:

$("p:last-of-type")

Try it Yourself »

Definition and Usage

The :last-of-type selector selects all elements that are the last child of a particular type of their parent element.

Tip:This selector is the same as :nth-last-of-type(1).

Tip:Please use:first-of-typethe selector to select all elements that are the first child of a particular type of their parent element.


Syntax

$(":last-of-type")


实例

Try it Yourself - Example

Select the last <p> element of all <div> elements
How to select the last <p> element of all <div> elements.

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


jQuery 选择器jQuery Selector

Other Extensions