JavaScript
  Home arrow JavaScript arrow Using the Style Object for Zebra Tables wi...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Moblin 
JMSL Numerical Library 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

Using the Style Object for Zebra Tables with CSS and JavaScript
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-07-02

    Table of Contents:
  • Using the Style Object for Zebra Tables with CSS and JavaScript
  • Building zebra tables with JavaScript
  • Building zebra tables with the style JavaScript object
  • Using the previous JavaScript function to build a zebra table

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Using the Style Object for Zebra Tables with CSS and JavaScript


    (Page 1 of 4 )

    Welcome to the final chapter of the series "Building Zebra Tables with CSS and JavaScript." In this article, I’ll teach you how to build zebra tables by using the popular “style” object, thus completing this educational four-part guide.

    If you’re a web designer who needs to display the tabular data of your web sites in a very professional way, then you should take a look at zebra tables, which, as you possibly know, use two alternating background colors for their respective odd and even rows.

    The downside of zebra tables is that they can be quite hard to build from scratch, particularly if they contain numerous rows. They have to be decorated alternately either by using an “id” or a “class” attribute, which you’d do normally with other web page elements.

    Fortunately for you and me, it’s perfectly possible to build a small JavaScript application that first iterates over the rows of the table in question, and then assigns the correct CSS styles to each of them. This will automate the whole process of constructing a zebra table.

    Of course, in order to implement this JavaScript-based approach and start constructing zebra tables here and there, you need a friendly guide that walks you through the right steps. So don’t waste any more time and begin reading this article series, since it will provide you with concise and useful material about using a combination of unobtrusive JavaScript and CSS to build fancy, eye-catching zebra tables that make your web site really shine!

    If you had the chance to read the preceding article of the series, you should be familiar with creating zebra tables by way of a simple JavaScript function that is responsible for automatically styling the even and odd rows of a specified table. I also incorporated the ability to work with tables that contain multiple <tbody> sections. This created a JavaScript-driven solution that can be used with a huge variety of web applications.

    In addition, to style the pertinent rows of a zebra table, the aforementioned JavaScript function used two different CSS classes that were assigned alternately to each row of the table. However, it’s also feasible to use a “style” object, instead of a CSS class, to manipulate the background colors of the appropriate rows. This eventually could be easier to code, even when this object isn’t standard compliant.

    With the preliminaries out of our way, let’s get started!

    More JavaScript Articles
    More By Alejandro Gervasio


       · In this final chapter of the series, you’ll learn how to build zebra tables by using...
       · Not every table has an element tbody.
       · Thank you for commenting on my article. Precisely, this condition was taken into...
     

    JAVASCRIPT ARTICLES

    - Using Mod_Security to Protect Your Server
    - Detecting and Countering Server Intrusions
    - Securing Your Web Server
    - Building a Secure Web Server
    - Protecting the Server
    - Book Review: Learning the Yahoo! User Interf...
    - Dynamically Generate a Selection List in a R...
    - Intergrate DWR into Your Java Web Application
    - Detect Browser Compatibility with the Reques...
    - Using the EXT JS Date Picker Widget
    - Ajax Hack for Entering Information Without R...
    - EXT JS 2.1 Overview
    - Using the Style Object for Zebra Tables with...
    - Binary Searching
    - An Improved Approach to Building Zebra Tables






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT