jQuery | find() with Examples
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.
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.
In the below code, all the “span” element connected to the “div” element get highlighted with the green color.
All the descendant element of the particular element can also be found with the help of find() function with some parameter.
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-
Return value: It returns all the children of the selected element.
In the below code, all the “span” elements of the “p” element gets selected and highlighted with green color.
You can learn jQuery from the ground up by following this jQuery Tutorial and jQuery Examples.