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 just one line of jQuery code:

    $('#foobar tr:visible:odd').addClass('roweven');

Now you're doing only half the work and letting the CSS cacading rules take care of the rest.

And if you need to support IE6, you might have trouble applying a background-color to a <tr> (I seem to recall having that problem in the past). If you do, you could do this instead:

tr td { background-color: #FFF; }
tr.roweven td { background-color: #F2F2F2; }


--Karl

____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com

Reply via email to