How to select ALL children (in any level) from a parent in jQuery?

To select all children from a parent in jQuery, use the find() method. You can try to run the following code to select ALL children in any level −


Live Demo

<!DOCTYPE html>
   .myclass * {
     display: block;
     border: 2px solid lightgrey;
     color: lightgrey;
     padding: 5px;
     margin: 15px;
  <script src=""></script>
    $('ul').find('*').css({"color": "red", "border": "2px solid green"});
<div class="myclass">
  <div style="width:400px;">div - great-grandparent
   <li>li- child - level 1
     <ul>ul- child - level 2
       <li>li- child - level 3</li>
       <li>li- child - level 3</li>


Updated on: 20-Jun-2020


Kickstart Your Career

Get certified by completing the course

Get Started