find() method in jQuery


The find() method used to finds the descendant elements of the selected element.

Syntax
//find all descendant elements of <div>
$("div").find("*");

//find all <p> elements of <div>
$("div").find("p");

//find all 'active' class elements of <div>
$("div").find(".active");

Example

The following example shows, how to find all .cls elements in descendant of <ul> using jQuery find() method.

Demo

 
<html>
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>   
  </head>
  <body>
    <ul>
      <li>HTML</li>
      <li class='cls'>CSS</li>
      <li>JS</li>
      <li class='cls'>jQuery</li>
      <li>PHP</li>
    </ul>
    <p class='cls'>Sample Text</p>
  <script>
    $(document).ready(function(){
      $("ul").find(".cls").css("color","red");
    });
  </script>
  </body>
</html>
Try it Yourself