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-
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
Nice :)
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
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');
>
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');
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('
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 {
> 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
9 matches
Mail list logo