Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This is just a note that there are much more reliable ways to achieve this than processing table mark-up with regular expressions.
jQuery provides even and odd selectors, so you can use that to deal with the problem at the DOM level:
http://api.jquery.com/odd-selector/
And you only need to utilise that approach for IE8 and below, as all modern browsers support the nth-child CSS selector which can be given even/odd arguments, and solve this problem purely at the CSS level:
http://stackoverflow.com/questions/5080699/using-css-even-and-odd-pseudo...
Comments
Comment #1
hgurol CreditAttribution: hgurol commentedDamn IE, doesnt support it. I tried the CSS approach and it was fast and easy. JQuery method seems more work.
Thanks for the tip.
Comment #1.0
hgurol CreditAttribution: hgurol commentedtypo
Comment #2
AstonVictor CreditAttribution: AstonVictor as a volunteer and at DevBranch commentedI'm closing it because the issue was created a long time ago without any further steps.
if you still need it then raise a new one.
thanks
Comment #3
jweowu CreditAttribution: jweowu at Catalyst IT commentedHi there,
This was only ever a Documentation task for the module's maintainers to note *somewhere* that there are some alternatives to using this module, but I don't see any notes to that effect on the current project page or in its readme file, and a glance at the code of version 2.0 indicates that it's still using regular expressions to parse table markup; so I think nothing has changed.
Perhaps you could update the project page description to include the alternatives I described? If you did that, I'd consider this issue closed.
And honestly, 12 years later I imagine there's no reason not to use the nth-child CSS selector.
* https://caniuse.com/mdn-css_selectors_nth-child
* https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-child