Search within a found object in jQuery
Let's now look at the find
method, which searches for elements by a given selector within those already found (that is, by descendants within the found elements).
Let's consider the method's operation on the following HTML code:
<div>
<p>text</p>
<p>text</p>
<p>text</p>
</div>
<div>
<p>text</p>
<p>text</p>
<p>text</p>
</div>
First we need to find all div
tags, prepend them with '!'
using prepend
, then find all paragraphs inside them using find
method and prepend them with '?'
:
$('div').prepend('!').find('p').prepend('?');
Find all b
with class www
, make them red, then among the found elements find elements with class test
and set their font size to 30px
.
Find all elements with class www
, make them red, then find paragraphs among the found elements and add text '!'
to the end of them.