Note that there are some explanatory texts on larger screens.

plurals
  1. POAlternating row colours in a tr class using XSL
    text
    copied!<p>I have a XSL document which has a varaible number of articles inserted into it. I need the background colours of the articles to alternate - "Odd" then "even"</p> <pre><code>&lt;xsl:for-each select="newsletter/section/article"&gt; &lt;tr class="odd" style="background-color: #efefef;"&gt; &lt;td valign="top"&gt; &lt;xsl:element name="a"&gt; &lt;xsl:attribute name="href"&gt; &lt;xsl:value-of select="link" /&gt; &lt;/xsl:attribute&gt; &lt;img align="left" valign="top" width="110" style="padding: 0 4px 4px 0; border:0;"&gt; &lt;xsl:attribute name="alt"&gt; &lt;xsl:value-of select="title" /&gt; &lt;/xsl:attribute&gt; &lt;xsl:attribute name="src"&gt; &lt;xsl:value-of select="img" /&gt; &lt;/xsl:attribute&gt; &lt;/img&gt; &lt;/xsl:element&gt; &lt;/td&gt; &lt;td valign="top" style="padding: 4px 4px 18px 0;"&gt; &lt;strong&gt; &lt;xsl:element name="a"&gt; &lt;xsl:attribute name="href"&gt; &lt;xsl:value-of select="link" /&gt; &lt;/xsl:attribute&gt; &lt;xsl:value-of select="title"/&gt; &lt;/xsl:element&gt; &lt;/strong&gt; &lt;br /&gt; &lt;xsl:value-of select="excerpt"/&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/xsl:for-each&gt; </code></pre> <p>Ive looked at this post: <a href="https://stackoverflow.com/questions/469917/html-table-with-alternating-row-colors-via-xsl">HTML table with alternating row colors via XSL</a></p> <p>but my case is different I believe. I just need to change the tr class on each iteration. Sorry for the weird formatting, I seem to be having problems pasting code in Chrome on here. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload