Open In App
Related Articles

Find all children of each division using jQuery

Improve Article
Save Article
Like Article

In this article, we will see how to find all children of each division element of HTML document.

To find all children in jQuery, you can simply use the .children() method with .css() method.

Methods used:

  • .children(): This method returns all direct children of the selected element.
  • .css(): This method is used to set or return one or more style properties for the selected elements.


  • Create the HTML page with various div elements with their children.
  • Using the .children() method, find the children of division element.
  • Using the .css() method, style those children element of division element.



<!DOCTYPE html>
    <script src=
    <meta charset="utf-8" />
    <meta name="viewport" 
          content="width=device-width" />
      body {
        text-align: center;
        font-size: 26px;
    <h2 style="color: green">GeeksForGeeks</h2>
    <p>This is a paragraph.</p>
      <p>This is a paragraph within a division.</p>
    <p>This is another paragraph.</p>
      This is a <span>span</span
      element within a division.
              .css("background-color", " lightgreen");

Output: In this example, first we have found all children of div element and applied background property of CSS. All the children of the division element should be highlighted on the webpage.

Last Updated : 27 Apr, 2021
Like Article
Save Article
Similar Reads
Related Tutorials