We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36924 ☆ A M B ☆
    • 298 Posts
    I have two classes: row and alt-row. Row provides white background, alt-row gray. How do I add each class to tables cells (TDs) alternatively and dynamically? I have the TRs (table rows) generated via getResources. Thanks.

    This question has been answered by absent42. See the first response.

    • discuss.answer
      • 42046
      • 436 Posts
      Use &tplOdd to specify a different tpl for every other row.
        • 40122
        • 330 Posts
        You can use CSS:

        tr:nth-child(even) {background: #CCC}
        tr:nth-child(odd) {background: #FFF}


        Or JQuery:

        $("tr:odd").addClass("alt-row");
          • 36924 ☆ A M B ☆
          • 298 Posts
          Shame I never replied. Thanks to you both, it worked though I decided on using the tplOdd snippet call property. Meltingdog answer also worked