jQuery find() Method Last Updated : 04 Jul, 2023 Comments Improve Suggest changes Like Article Like Report The find() is an inbuilt method in jQuery which is used to find all the descendant elements of the selected element. It will traverse all the way down to the last leaf of the selected element in the DOM tree. Syntax: $(selector).find() Here selector is the selected elements of which all the descendant elements are going to be found. Parameters: It does not accept any parameter. Return Value: It returns all the descendant elements of the selected element. jQuery code to show the working of this function: Code #1: In the below code, all the "span" element connected to the "div" element get highlighted with the green color. html <html> <head> <style> .descendants * { display: block; border: 2px solid grey; color: lightgrey; padding: 5px; margin: 15px; } </style> <script src="https://ajax.googleapis.com/ajax/libs/ jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function() { $("div").find("span").css({ "color": "green", "border": "2px solid green" }); }); </script> </head> <body> <div class="descendants" style="width:500px;">This is the current element !!! <p>This is the paragraph element !!! <span> This is span element !!!</span> </p> <p>This is the paragraph element !!! <span>This is span element !!!</span> </p> </div> </body> </html> Output: All the descendant element of the particular element can also be found with the help of find() function with some parameter. Syntax: $(selector1).children("selector2") Here selector1 is the selected element whose all the descendant element are going to be found. Parameters: It accepts a parameter which is specified below- selector2: This is the just "*" sign which return all the children of the selected element. Return value: It returns all the children of the selected element. Code #2: In the below code, all the "span" elements of the "p" element gets selected and highlighted with green color. html <html> <head> <style> .descendants * { display: block; border: 2px solid lightgrey; color: grey; padding: 5px; margin: 15px; } </style> <script src="https://ajax.googleapis.com/ajax/libs/ jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function() { $("p").find("*").css({ "color": "green", "border": "2px solid green" }); }); </script> </head> <body> <div class="descendants" style="width:500px;">This is the current element ! <p>This is the paragraph element !!!! <span>This is span 1 !!!</span> <span>This is span 2 !!!</span> <span>This is span 3 !!!</span> <span>This is span 4 !!!</span> </p> </div> </body> </html> Output: jQuery is an open source JavaScript library that simplifies the interactions between an HTML/CSS document, It is widely famous with it's philosophy of “Write less, do more". You can learn jQuery from the ground up by following this jQuery Tutorial and jQuery Examples. Comment More infoAdvertise with us Next Article jQuery first() Method K kundankumarjha Follow Improve Article Tags : JavaScript Web Technologies JQuery jQuery-Traversing Similar Reads jQuery add() method The jQuery add() method is used to add elements to the existing group of elements. This method can add element to the whole document, or just inside the context element if the context parameter is defined. Syntax: $(selector).add(element, context_parameter) Here selector helps to find the matching e 1 min read jQuery addBack() Method The addBack() is an inbuilt method in jQuery that adds the previous set of elements to the current set. This method adds previous DOM tree elements to the current set and maintains them in the internal stack which will take care of changes to the matched set of elements. Syntax: .addBack(selector) P 2 min read jQuery children() Method jQuery children() method is used to find all the child elements of the selected element. This children() method in jQuery traverses down to a single level of the selected element and returns all child elements. Syntax:$(selector).children()Parameter: It accepts an optional parameter that specifies t 2 min read jQuery closest() Method The closest() is an inbuilt method in jQuery that returns the first ancestor of the selected element in the DOM tree. This method traverses upwards from the current element in the search of first ancestor of the element. Document Object Model (DOM) is a World Wide Web Consortium standard. This defin 2 min read jQuery contents() Method The contents() is an inbuilt method in jQuery that returns all the direct children, including text and comment nodes for the selected element. Syntax: $(selector).contents()Parameter: It does not accept any parameter. Return Value: It returns all the direct children elements of the selected element. 2 min read jQuery Misc each() Method The each() Method in jQuery is used to specify the function to run for each matched element. Syntax: $(selector).each(function(index, element)) Parameters: This method accepts single parameter function(index, element) which is mandatory. It is used to run for each matched element. It contains two pa 2 min read jQuery eq() Method The eq() method is an inbuilt method in jQuery that is used to locate the selected elements directly and returns an element with a specific index. Syntax: $(selector).eq(index)Parameters: Here the parameter "index" specifies the index of the element.Can either be positive or a negative number. NOTE: 2 min read jQuery filter() Method The jQuery is a very powerful tool which helps us to incorporate a variety of DOM traversal methods to select elements in a document randomly or in sequential order. Most of the DOM traversal methods do not modify the elements whereas they filter them out upon the given conditions. The filter() meth 2 min read jQuery find() Method The find() is an inbuilt method in jQuery which is used to find all the descendant elements of the selected element. It will traverse all the way down to the last leaf of the selected element in the DOM tree. Syntax: $(selector).find() Here selector is the selected elements of which all the descenda 3 min read jQuery first() Method The jQuery first() method selects and returns the first element from a set of matched elements. It's commonly used to manipulate or retrieve the first element within a group, ensuring that operations only apply to the first match.Syntax: $(selector).first()Here selector is the main class of all the 2 min read Like