treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Even & Odd Table Row Colours

  • I was hoping someone might have a solution to creating Even and Odd background colours to table rows. The data would be coming from a database. I was hoping for an all CSS solution, but am really open to anything. I read something about tr:nth-child but it doesn't seem to work in IE.

    Any help would be greatly appreciated.
  • hi,
    its hard to tell it that way you have to send your table structure which you want to fetch from database
  • This looks like it's just what you wanted...
    http://colorcharge.com/2007/12/13/jquery-alternate-table-rows/
  • thank you all. I'm going to give these suggestions a try.

    Take Care
  • Yeah it's trivially easy with something like jQuery...

    You can use a selector like $("td:odd")

    then...

    $("td:odd").addClass("oddRow")

    Then apply styling for the odd rows in your CSS.