The parent method in jQuery

We've already covered the parent method a bit when we discussed the parent pseudo-class. Let me remind you that the parent method and the parent selector do different things: the first finds the parent of an element, and the second finds all non-empty elements (that are parents).

In the following example, we will find the element #test, then find its parent with parent and set the text '!' to it. Let's say we have the following HTML code:

html<p>outside</p>
<div>
  <p>inside</p>
  <p>inside</p>
  <p id="test">inside</p>
  <p>inside</p>
  <p>inside</p>
</div>
<p>outside</p>

Now we write the parent method into the Javascript code:

javascript$('#test').parent().html('!');

Don't forget that you can pass a selector to this method for additional filtering of parents.

Задание 1

Find the parent of the element with class www and color it red.

Задание 2

Find the parents of all b tags and make them red.

Задание 3

Find the parents of all tags b, and color those with class test red.