can someone explain why in the JQuery lesson “Target a Specific Child of an Element Using jQuery” we used the .target to target the second child and we didn’t use the .well class?
the target class is used in the buttons, and if we wanted to target the well class second child shouldn’t we use the .well:nth-child(2) insted of .taregt:nth-child(2) ?
I want to know the answer to this question as well.
Think of it this way. When you say
$('.target:nth-child(2)'), you mean those
.target elements that are the second child of their respective parent elements.
If you think about it in CSS terms, maybe it’ll make more sense.
/* styles for .target */
/* adding psuedo-classes (such as nth-child) to .target
will still style (some) .target elements */
this MAY or may NOT help -
and TRAVERSING the DOM -