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

jQuery :last-child Selector

jQuery :last-child Selector

jQuery selector jQuery selector

Example

Select the last

child element of its parent:

$("p:last-child")

Try it »


Definition and Usage

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

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


Syntax

$(":last-child")


Try it - Example

Select all

The last of the element

Element
How to select all

The last of the element

.

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

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


jQuery selector jQuery selector