Target the Parent of an Element Using jQuery missing info

Target the Parent of an Element Using jQuery missing info
0

#1

In this exercise, it starts to talk about inheritance, then drops the ball…

Every HTML element has a parent element from which it inherits properties.

For example, your jQuery Playground h3 element has the parent element of

, which itself has the parent body.

jQuery has a function called parent() that allows you to access the parent of whichever element you’ve selected.

Here’s an example of how you would use the parent() function if you wanted to give the parent element of the left-well element a background color of blue:

$("#left-well").parent().css(“background-color”, “blue”)

Give the parent of the #target1 element a background-color of red.

Ideally, it should point out that not only does the the parent turn blue, but so does left-well, in order to firmly seat in the learner’s mind the idea of inheritance. Yes, I know, it happens when you code in red - but some people will not notice that; not every user is observant. :open_mouth: :stuck_out_tongue_closed_eyes:

Doing this provides a better lead in to the next exercise, “Target the Children of an Element Using jQuery”, which also discusses inheritance.