Child Selector (“parent > child”)

child selector

Description: Selects all direct child elements specified by "child" of elements specified by "parent".

  • version added: 1.0jQuery( "parent > child" )

    parent: Any valid selector.

    child: A selector to filter the child elements.

The child combinator (E > F) can be thought of as a more specific form of the descendant combinator (E F) in that it selects only first-level descendants.


Places a border around all list items that are children of <ul class="topnav"> .

<!doctype html>
<html lang="en">
  <meta charset="utf-8">
  <title>child demo</title>
  body {
    font-size: 14px;
  <script src="https://code.jquery.com/jquery-3.5.0.js"></script>
<ul class="topnav">
  <li>Item 1</li>
  <li>Item 2
    <li>Nested item 1</li>
    <li>Nested item 2</li>
    <li>Nested item 3</li>
  <li>Item 3</li>
$( "ul.topnav > li" ).css( "border", "3px double red" );


© The jQuery Foundation and other contributors
Licensed under the MIT License.