jQuery Tutorial Tutorials - jQuery :only-child selector

:only-child selector

The jQuery :only-child selector is used to select the element that is the only child element of their parent.

jQuery :only-child selector Syntax

$(':only-child')

jQuery :only-child selector Examples

In below example,We will add background color for each p element that is the only child of its parent.

Try now

Date:2019-08-18 13:05:27 From:www.Lautturi.com author:Lautturi