Try:
$(".table tbody td:nth-child(4)").addClass("col4");
Note: I put 4 here because it is :eq(n)based on zero and :nth-child(n)is unidirectional.
You stumbled upon a key difference between the two. eq(3)will return exactly one element, the fourth of the entire set. Just as it :firstreturns only one element (max), while it :first-childcan return a lot.
source
share