Re: [jQuery] Re: jQuery does not stripe visible table rows correctly

2010-01-01 Thread Paul Kim
Thank you all for your helpful suggestions. On Fri, Jan 1, 2010 at 2:37 PM, Karl Swedberg wrote: > > On Jan 1, 2010, at 3:53 PM, Michael Geary wrote: > > I wouldn't use either version. > > Instead, I would change your CSS from: > > tr.rowodd { background-color: #FFF; } > tr.roweven { background-

Re: [jQuery] Re: jQuery does not stripe visible table rows correctly

2010-01-01 Thread Karl Swedberg
On Jan 1, 2010, at 3:53 PM, Michael Geary wrote: I wouldn't use either version. Instead, I would change your CSS from: tr.rowodd { background-color: #FFF; } tr.roweven { background-color: #F2F2F2; } to: tr { background-color: #FFF; } tr.roweven { background-color: #F2F2F2; } and then use j

[jQuery] Re: jQuery does not stripe visible table rows correctly

2010-01-01 Thread Šime Vidas
Nice :)

Re: [jQuery] Re: jQuery does not stripe visible table rows correctly

2010-01-01 Thread Michael Geary
I wouldn't use either version. Instead, I would change your CSS from: tr.rowodd { background-color: #FFF; } tr.roweven { background-color: #F2F2F2; } to: tr { background-color: #FFF; } tr.roweven { background-color: #F2F2F2; } and then use just one line of jQuery code: $('#foobar tr:visib

Re: [jQuery] Re: jQuery does not stripe visible table rows correctly

2010-01-01 Thread Paul Kim
Thank you. Have a great New Year. 2010/1/1 Šime Vidas > Well, definitely the shorter version :) > You can put a comment above to remind you that :even and :odd are > tricky > > // Remember, :even and :odd are zero-based, so it's reversed > $('#foobar tbody tr:visible:even').addClass('rowodd'); >

[jQuery] Re: jQuery does not stripe visible table rows correctly

2010-01-01 Thread Šime Vidas
Well, definitely the shorter version :) You can put a comment above to remind you that :even and :odd are tricky // Remember, :even and :odd are zero-based, so it's reversed $('#foobar tbody tr:visible:even').addClass('rowodd'); $('#foobar tbody tr:visible:odd').addClass('roweven');

Re: [jQuery] Re: jQuery does not stripe visible table rows correctly

2010-01-01 Thread Paul Kim
Thanks for your reply. Your solution works. I had a feeling that :even and :odd filters are zero-based, but found that to be "odd" in this situation. So now that I have 2 ways to stripe visible table rows using jQuery, which solution do you prefer? $('#foobar tbody tr:visible:even').addClass('

[jQuery] Re: jQuery does not stripe visible table rows correctly

2010-01-01 Thread Šime Vidas
Also, you really don't need two counters (i and j) var rows = $('#foobar tbody tr:visible'); for (var i = 0; i < rows.length; i++){ if ((i + 1) % 2 == 0) { rows.eq(i).addClass('roweven'); } else {

[jQuery] Re: jQuery does not stripe visible table rows correctly

2010-01-01 Thread Šime Vidas
> The problem is that jQuery assigns a class of 'roweven' to odd > numbered elements and a class of 'rowodd' to even numbered > elements across all browsers. I've tested this on jQuery 1.3.2 and > jQuery 1.3.1. The :even and :odd filters are zero-based, so if you select (in your example) 10 row