Path: csiph.com!2.us.feeder.erje.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.datemas.de!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: apply classes to table rows after table is rendered, how Date: Sat, 02 Jan 2016 22:19:07 +0100 Organization: PointedEars Software (PES) Lines: 24 Message-ID: <15784927.fxi3qVJc2V@PointedEars.de> References: Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1451769549 8079 eJwVx8kRwDAIA8CWwBxC5TiK3X8JmexvK9pbyK7OunURZjxLfB9OyPeR+WAgzb9VJBsZIAJbHxKeEI4= (2 Jan 2016 21:19:09 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Sat, 2 Jan 2016 21:19:09 +0000 (UTC) User-Agent: KNode/4.14.2 X-User-ID: eJwFwQkBwDAIA0BLjBBK5fAU/xJ2R/jnfczpxuWiwFuUe0qndNXnRTMg03WD806LxoomwlLGzORlNj6IFn5QshVH Cancel-Lock: sha1:wmmbjfXC8NjsFckenhWNVJ9pb8Y= X-NNTP-Posting-Host: eJwFwYEBwDAEBMCVEL6Mk/L2HyF3caDozxHw2NjaNevOca266+j52Zhqq2HmWY4KQIpScB832RID Xref: csiph.com comp.lang.javascript:29109 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: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not cc me. / Bitte keine Kopien per E-Mail.