The find method

The find method searches for elements within elements already found.

Syntax

Search by selector:

javascript.find(selector);

You can search not only by selector, but also by DOM element or jQuery object:

javascript.find(jQuery object or DOM element);

Example

Let's find all div tags, prepend them with '!' using prepend, then find all paragraphs inside them using find and prepend them with '?':

html<div>
  <p>text</p>
  <p>text</p>
  <p>text</p>
</div>
<div>
  <p>text</p>
  <p>text</p>
  <p>text</p>
</div>
javascript$('div').prepend('!').find('p').append('?');

HTML the code will look like this:

html<div>
  !
  <p>text?</p>
  <p>text?</p>
  <p>text?</p>
</div>
<div>
  !
  <p>text?</p>
  <p>text?</p>
  <p>text?</p>
</div>

See also

  • method filter,
    which filters the elements in a set
  • method has,
    which filters the set of selected elements by descendants