Latest web development tutorials

jQuery: last-child selector

jQuery selector jQuery selector

Examples

Each <p> element selected element belongs to the last child of its parent element:

$("p:last-child")

try it"

Definition and Usage

: Last-child selector selects all elements belonging to the last child element of its parent element.

Tip: Use the : first-child selectors to select elements that belong to the first child element of its parent element.


grammar

$(":last-child")


Examples

Try - Example

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

: last-child between different: last and
Demo: different last-child choose between: last and.

: last,: last-of-type different between the: last-child and
Demo: last,: different last-of-type selector between: last-child and.


jQuery selector jQuery selector