jQuery :last-childSelector

jQuery 选择器jQuery Selectors

Examples

Selects the last <p> child element of its parent:

$("p:last-child")

Try it Yourself »

Definition and Usage

The :last-child selector selects the last child element of its parent.

Tip:Please use:first-childselector to select the first child element of its parent.


Syntax

$(":last-child")


实例

Try it Yourself - Examples

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

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

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 Selectors

Other Extensions