Target the parent of an element using jquery

Target the parent of an element using jquery
0.0 0

#1

"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."

My solution for this problem is as follows.

I am being told that my answer is incorrect, however it seems to match up with the solution in the help link. But it does not change the “left well” backround to red.

Can anyone see where i made a mistake?


#2

You spelled “background” wrong.


#3

wow, i feel like a fool. thank you


#4

image