oooops.. i totally missed the ":visible" selector on the docs
On Jan 12, 3:36 pm, Karl Swedberg <k...@englishrules.com> wrote: > Simpler still would be this: > > $(this).find("tbody tr:visible:even").addClass("alt"); > > --Karl > > ____________ > Karl Swedbergwww.englishrules.comwww.learningjquery.com > > On Jan 12, 2009, at 2:52 PM, brian wrote: > > > > > Right - that's way simpler. Yay, jQuery! > > > On Mon, Jan 12, 2009 at 2:46 PM, MorningZ <morni...@gmail.com> wrote: > > >> Should work: > > >> $(this).find("tbody tr").not(":hidden").filter(":even").addClass > >> ("alt"); > > >> On Jan 12, 1:08 pm, brian <bally.z...@gmail.com> wrote: > >>> 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?