Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi there
i have made a foreach loop in xslt that works, the thing is that i want every second <tr> to have a class name.
Try something like this:
<xsl:if test="position() mod 2 = 1"> <xsl:attribute name="class">odd</xsl:attribute></xsl:if>
hth, Thomas
Hi Henrik you can do it with something like this:
<xsl:for-each select="something..."> <tr> <xsl:attribute name="class"> <xsl:choose> <xsl:when test="position() mod 2 = 1">altRow</xsl:when> <xsl:otherwise></xsl:otherwise> </xsl:choose> </xsl:attribute> <td> tralala... </td> </tr></xsl:for-each>
This is from the top of my head, so please take a minute to see if anything is wrong. But something like that should work.
/Kim A
By the way, you could also do this with jQuery if you prefer that.
$("tr:has(td):even").addClass("evenRow");$("tr:has(td):odd").addClass("oddRow");
This would get all of your <tr>'s that contains one or more <td>'s (which mean that a <tr> that includes your <th>'s wouldn't be selected), and give the even rows a class of evenRow, and the odd rows would get a class of oddRow.
Just another approach.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
table with alternate rows
Hi there
i have made a foreach loop in xslt that works, the thing is that i want every second <tr> to have a class name.
Try something like this:
<xsl:if test="position() mod 2 = 1">
<xsl:attribute name="class">odd</xsl:attribute>
</xsl:if>
hth, Thomas
Hi Henrik you can do it with something like this:
This is from the top of my head, so please take a minute to see if anything is wrong. But something like that should work.
/Kim A
By the way, you could also do this with jQuery if you prefer that.
This would get all of your <tr>'s that contains one or more <td>'s (which mean that a <tr> that includes your <th>'s wouldn't be selected), and give the even rows a class of evenRow, and the odd rows would get a class of oddRow.
Just another approach.
/Kim A
is working on a reply...