The way I sometimes do this with PHP is to set a $counter var and then
use the modulo operator on the incremented counter to write the
classname for the row. So, something like this might work:

// where you have CSS classes Row0 & Row1

$(this).find("tbody tr:visible").each(function(i, el)
{
    $(el).addClass('Row' + ((++i + 2) % 2));
});

Or something like that.

On Mon, Jan 12, 2009 at 12:55 PM, rolfsf <rol...@gmail.com> wrote:
>
> I have a table with multiple tbody's. Within each tbody there are a
> number of rows that can be hidden or shown by clicking on a link. I'm
> using the following function to stripe alternating rows:
>
>        jQuery.fn.stripeTable = function(){
>                        $(this).find("tbody 
> tr:nth-child(even)").addClass("alt");
>        }
>
> but now I'm trying to account for hidden rows, so that when I click to
> hide some rows I the striping is revised
>
> I can't quite work out the syntax to filter first for visible rows,
> then find even rows among those
>
> can anyone assist?
>
>

Reply via email to