Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #29109

Re: apply classes to table rows after table is rendered, how

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: apply classes to table rows after table is rendered, how
Date 2016-01-02 22:19 +0100
Organization PointedEars Software (PES)
Message-ID <15784927.fxi3qVJc2V@PointedEars.de> (permalink)
References <n67ddd$k5k$1@dont-email.me>

Show all headers | View raw


Mike S wrote:

> I generate a table (using PHP) that has alternating white/off-white row
> background colors for readability. I was asked to make the table
> sortable, so of the background colors no longer alternate when the table
> is sorted on various column data. What do I have to read to learn how to
> apply alternating row background colors to a table that is already
> rendered?

Use CSS *selectors*: The :nth-child pseudo-class, and add or remove an 
“odd”/“even” class name from the “tr” element in question when you sort the 
table as a fallback.  Then know that this has already been written and 
published several times; Google is your friend.  See the ECMAScript Support 
Matrix (sig) for an example of using both :nth-child() and classes for 
alternating rows.

The “From” header field of your posting is lacking your last name, Mike S 
#74656.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

apply classes to table rows after table is rendered, how Mike S <mscir@yahoo.com> - 2016-01-01 18:44 -0800
  Re: apply classes to table rows after table is rendered, how Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2016-01-02 11:21 -0200
    Re: apply classes to table rows after table is rendered, how Mike S <mscir@yahoo.com> - 2016-01-02 18:30 -0800
  Re: apply classes to table rows after table is rendered, how Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-01-02 22:19 +0100
  Re: apply classes to table rows after table is rendered, how Mike S <mscir@yahoo.com> - 2016-01-02 18:29 -0800
  Re: apply classes to table rows after table is rendered, how Aleksandro <aleksandro@gmx.com> - 2016-01-04 13:31 -0300
  Re: apply classes to table rows after table is rendered, how Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-01-04 17:39 +0100

csiph-web