Targeting the second child with jquery

Targeting the second child with jquery
0.0 0

#1

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) ?


#2

I want to know the answer to this question as well.


#3

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 */
.target {
  // ...
}

/* adding psuedo-classes (such as nth-child) to .target
   will still style (some) .target elements */
.target:nth-child(2) {
  // ...
}

#4

this MAY or may NOT help -

http://api.jquery.com/children/

and TRAVERSING the DOM -