backflip wrote:

I'm using the following code to style a table:
   $("table.xy tr:nth-child(odd)").addClass("odd");
But before doing that I'm hiding some rows:
   $("tr#xy").hide();

Now the zebra pattern isn't working any more (it's an abnormal zebra), of
course. How to apply the zebra-stuff just to the visible rows?

This is not tested, but something like this might do it:

    $("table.xy tr:visible").each(function(index) {
        if (index %2 == 1) {
            $(this).addClass("odd");
        }
    });

But if rows are being dynamically hidden and shown, you will need an "else" and some "removeClass()" calls after each change to the rows' visibility.

Cheers,

  -- Scott

Reply via email to