Which child element is it?

Tell us what’s happening:

in this challenge I have a doubt the code $(".target:nth-child(3)").addClass(“animated bounce”);, how does it find out the child of which parent I am talking about

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36.

Challenge: Target a Specific Child of an Element Using jQuery

Link to the challenge:

So, jQuery targets the element class at first and then look for the nth child. Here’s a detailed explanation:

                ↓//declared to look for the nth child
$(".target:nth-child(3)")←//Then ask it to look for the 3rd child
    ↑//jQuery finds all element that have a class target

It is actually just a normal CSS selector. That’s what jQuery’s powers are. You can use ANY CSS selectors. Learn more about CSS :nth-child() here:

1 Like

thanks :sweat_smile: :sweat_smile:

1 Like

No problem. Glad I helped. Don’t be scared to ask questions, that’s why this forum exist, so you can ask for help and explanation. Now you understand how it works.
Happy Coding!! :slightly_smiling_face:

1 Like