Hi Snef,

Since you asked me directly, I thought I should put in my answer, for the record. Here goes:

What they said ... :-)

(i.e. I agree with Allex and Rob)

Cheers,

--Karl

On Feb 5, 2008, at 11:13 AM, Smith, Allex wrote:


Rob definitely has the best answer here.

Structure your table like so:

<table>
        <caption>Captions are good</caption>
        <thead>
                <tr>
                        <th>header</th>
                        <th>row</th>
                </tr>
        </thead>
        <tfoot>
                <tr>
                        <td>footer</td>
                        <td>row</td>
                </tr>
        </tfoot>
        <tbody>
                <tr>
                        <td>row</td>
                        <td>one</td>
                </tr>
                <tr>
                        <td>row</td>
                        <td>two</td>
                </tr>
        </tbody>
</table>

Then you don't have to worry about the checking for the first row and it will not be part of your structure.

Allex

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of RobG
Sent: Tuesday, February 05, 2008 5:06 AM
To: jQuery (English)
Subject: [jQuery] Re: Zebra striping in tables





On Feb 5, 7:57 pm, Snef <[EMAIL PROTECTED]> wrote:
Karl,

Again, many thanks. Only just one question...

I have used your one-liner like this:

$("table tr:nth-child(even)").css("background", "#cccccc");

I played around with the :not(:first) to eliminate the first row of
each table but i do not get it working. Is this possible to use this,
or is it better to just change all the firstrows after yoour one-
liner? (at the end, i can use a special classname for the first row,
but I'm curious to know if it can work without it!)

Consider putting your header rows in a thead element, then use:

  $("tbody ...


--
Rob

Reply via email to