:only-child selector

:only-child Selector

only-child selector

Description: Selects all elements that are the only child of their parent.

  • version added: 1.1.4jQuery( ":only-child" )

If the parent has other child elements, nothing is matched.

Example:

Change the text and add a border for each button that is the only child of its parent.

<!doctype html>
<html lang="en">
<