This project is archived and is in readonly mode.

#829 ✓invalid

Zebra table adds 'table-tr-odd' to even tbody rows

Reported by jtheory | January 13th, 2010 @ 12:39 AM

From HtmlTable.Zebra.js in More

zebra: function(row, i){

return row[((i % 2) ? 'remove' : 'add')+'Class'](this.options.classZebra);


This is supposed to add classZebra to ODD rows.
But when "i" is not divisible by 2, the result is 1 (evals to true) so 'removeClass' is the result.

Comments and changes to this ticket

  • fakedarren

    fakedarren February 8th, 2010 @ 01:34 PM

    • State changed from “new” to “invalid”
    • Milestone cleared.

    Programatically you are correct, but because arrays start from 0 you have to shift by one if you want it to be correct in your CSS - index 2 (even) is the third row (odd).

  • jtheory

    jtheory February 9th, 2010 @ 04:00 AM

    Ah, so you're intentionally flipping to 1-indexed counting for "even"/"odd". I missed that, since it looks wrong to me to highlight a single displayed row... but it seems like there's a fairly even mix of how to do it online, and it's just a bit different CSS to highlight the (1-indexed) even rows. Thanks!

  • Jan Kassens

    Jan Kassens August 30th, 2010 @ 08:46 PM

    • Tag cleared.
    • Milestone order changed from “0” to “0”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins