I have a table whose tds are created dynamically. I know how to get the first and last child but my question is:
table
td
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.
td:nth-child(2)
td:nth-child(3)
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.
2.1m questions
2.1m answers
60 comments
57.0k users