Question about jquery targeting specific child element

So in pic bellow i learned how to select specific child of element, previously i found out that parent, parents and children functions work for nested elements only, finnaly. So now im curious if function .target:nth- child(n) targets child of all nested elements in a document? Example is down bellow.

It targets children who’s order within the nearest parent is a specific value (nth). See the following thread with examples on using nth-child function.

Ok so it basicaly targets every single for example second element of every div in a document? Did i understand this correctly? nth means nearest?

Try reading the official documentation of nth-child (below) and see if it answers some of your questions. In the thread I posted above, there are some very good examples of how it is used.

The best way to see if you understand how to use this function is to play around with the code to see what different configurations do to the elements.

1 Like