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

hgurol’s picture

Damn IE, doesnt support it. I tried the CSS approach and it was fast and easy. JQuery method seems more work.
Thanks for the tip.

hgurol’s picture

Issue summary: View changes

typo

AstonVictor’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

I'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

jweowu’s picture

Hi 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