A question about jQuery target function

A question about jQuery target function
0.0 0

#1

Hey all, I am new to FCC and doing the jquery challenges. I was just wondering how the “$(”.target:nth-child(2)").addClass(“animated bounce”);" knows it is targeting both wells instead of one or the other in the challenge? It doesn’t seem like there is anything in that code that tells it to target nth elements in both wells. Is it targeting both just because of where the code is placed? How would I go about having it target only elements in the left or right well?

Thanks!
Eric


#2

It’s targeting both because both of them are the second child of their respective wells.


#3

Ahh I see, so is that code targeting both wells because there is nothing to define which specific well to target? What would need to change if I wanted it to only target the 2nd child of the left well?

Thanks for your help, I want to have as thorough an understanding of what is going on as possible!


#4

I think $('#left .target:nth-child(2)') will do.


#5

Perfect, I think I understand now. Thanks!