For details about nth-child and nth-of-type in jQuery, jquerynth-child
First, paste the HTML code:
<! DOCTYPE html>
The display result of the entire page is:
Please replyFrom left to rightWhich lines of buttons have the background color changed?
Click the first one:
4,10
Click the second one:
7, 10
Click third:
2, 5, 10
Click Fourth:
2, 6, 10
Are you correct? If it is correct, click Close in the upper right corner.
From this we can see that
A: nth-child (B) indicates that the B-th element of the parent element is exactly all A elements of.
A: nth-of-type (B) indicates the set of all A elements of Element B of the parent element.
Have you seen the difference? Nth-of-type essentially performs A filtering during indexing. The parent element only contains A, so as long as B <A has A value in the number of parent elements, nth-child is not filtered. It is the nth B of all elements in the parent element. If it is A, it is obtained and may not be obtained.
If you can understand the above problems, then the difference between eq () is obvious. A: eq (B), the B of all selected, it has nothing to do with the parent element.