jQuery :onlychild Selector (original) (raw)

jQuery :only-child Selector

Last Updated : 11 Jul, 2025

It is a jQuery Selector used to select every element that is the only child of it's parent i.e only a single child is selected.

Syntax:

$(":only-child")

Example 1: In this example, we are using only-child selector.

HTML `

jQuery :only-child Selector

Geeks

Geeks for Geeks


Geeks for Geeks

jQuery:Only Child Selector


`

Output:

Example 2: In this example, we are using only-child selector.

HTML `

jQuery :only-child Selector

Geeks

Geeks for Geeks


Geeks for Geeks


Geeks for Geeks


`

Output: