jQuery parent > child Selector

The parent > child selector in jQuery is used to select all elements that are a direct child of the specified element.


The syntax is as follows −

("parent > child")


Let us now see an example to implement the jQuery parent > child selector 

 Live Demo

<!DOCTYPE html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
      $("div > span").css("color", "red");
div {
   border:1px solid black;
<h2>Demo Heading</h2>
<p>This is demo text.</p>
<span>span outside p element</span>
<p>This is demo text.</p>
<p>This is demo text.</p>
<p>This is demo text. <span>span inside p element.</span></p>
<p>This is demo text.</p>


This will produce the following output −