I have a table
whose td
s are created dynamically. I know how to get the first and last child but my question is:
Is there a way of getting the second or third child using CSS?
For modern browsers, use td:nth-child(2)
for the second td
, and td:nth-child(3)
for the third. Remember that these retrieve the second and third td
for every row.
If you need compatibility with IE older than version 9, use sibling combinators or JavaScript as suggested by Tim. Also see my answer to this related question for an explanation and illustration of his method.