Adding multiple classes on table td (HTML/CSS)

TinoTriste

New Member
I have a dynamic table that needs to assign each TD it's own class. In the example below, .one is being applied to all TDs for this table. Using just CSS (or Jquery), can I assign td classes .two and .three to the second and third children of this table?[please do not add class names to TD; this is a dynamic table]Dynamic - To clarify, the numbers of TDs/TRs in the table are unknown. Therefore, the CSS has to be smart enough to adjust regardless if there are 3 TDs/TRs or 10 TDs/TRs.HTML:\[code\]<table id="foo"> <tr> <td>One</td> </tr> <tr> <td>Two</td> </tr> <tr> <td>Three</td> </tr></table>?\[/code\]CSS:\[code\] #foo{ position: absolute; display: block; background: gray; color: white; height: 67px; width: 500px; border: 1px solid black;}tr { width: 500px; border: 1px solid black;}.one td { background: red; display: block; position: relative; left: 0px; width: 15px; border: 1px solid black; height: 19px; text-indent: 22px;}.two td { background: green; display: block; position: relative; left: 0px; width: 15px; border: 1px solid black; height: 19px; text-indent: 22px;}\[/code\]See JS Fiddle here: http://jsfiddle.net/bigthyme/kM7H9/
 
Back
Top