.find()
methodThe .find(selector)
method in jQuery is used to filter the descendants of each element in the current set of matched elements by a selector, jQuery object, or element.
.find()
method Syntax.find(selector) .find(element)
.find()
method ExampleBegins with the current element,searches through their descendants step by step,return all matching elements.
Finds matching element and highlight them.
HTML
<ul> <li class="category">Language <ul> <li class="lang">Java <ul> <li>Java tutorial</li> <li>Java Examples</li> </ul> </li> <li class="lang">Python <ul id="python"> <li>Python tutorial</li> <li id="pyex">Python Examples</li> </ul> </li> </ul> </li> <li class="category">Tools</li> <li class="category">Lautturi</li> </ul>
jQuery
$("#python").find('li').css('background','cyan'); // return all matched elements ,not only the first. // [<li>,<li id="pyex">] $(".category").find('#pyex').css('background','cyan'); // [<li id="pyex">] var item = $( ".lang" )[0]; $(".category").find(java).css('background','cyan'); // [<li class="lang">Java]