Navigation Menu
Alphabetical Listing
Site Contents

Site FAQ
About JSS
JavaScript Forum
JavaScript Tutorial
Friends of JSS

Link to Us
JavaScript Help
Contribute a script
Technology Jobs

Become a Partner

Internet.commerce

Be a Commerce Partner














Internet.com

IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

Developer Channel

FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

Great Sites

DocJavaScript.com
dhtml.com
The Freebie Directory
TheFreeSite.com

Browse Doc JS's Tips!


Hiermenus Central


Promotions

Free Announcements


Social Bookmark

General

Tired of adding even and odd classes to your tables to distinguish the rows? This script will do it for you automatically. You can even use it with lists!


Browsers Hits Percent
Mozilla Firefox 15772 73%
Internet Explorer 6 4581 21.2%
Mozilla 442 2%
Opera 122 0.5%
Safari 100 0.4%
Netscape 99 0.4%

Notes

Source Code

Paste this source code into the designated areas.

External file

Paste this code into an external JavaScript file named: autoRows.js


CSS

Paste this code into your external CSS file or in the <style> section within the HEAD section of your HTML document.


Head

Paste this code into the HEAD section of your HTML document.


Body

Paste this code into the BODY section of your HTML document


User Comments

Add a comment, suggestion, or correction
[For questions about usage, consult the Notes tab above or visit the JavaScript forum. Do not include more than two (2) lines of code in your comments. If you have suggestions or corrections, you can submit them to us.]

    
   
       
[optional]
 
[optional]

   

Comments feed Comment Feed RSS 2.0

1. From: Jim Williams
Auto colored rows JS
09/08/2007 12:31:43

The script appears to affect all tables (rows) on the page. What If you have several tables on the page, but want to apply the alternate colored rows to only one table? How do you get the script to ignore the other tables?

2. From: Lee (Admin)
10/03/2007 15:49:27

If you just want to color one of the tables (or lists) instead of using document.getElementByTagName("tr"); (for tables) give the table an id and use document.getElementById("myTablesId").getElementsByTagName("tr");


Do you write JavaScripts?
If you do, why not submit them to us?
We'll give you credit and a link back to your Web site.