2009
01.27

Who says we need jquery? Prototype can be just as effective. Here’s a little snippet for decorating an html table with alternating background color rows:

document.observe('dom:loaded', function(){
  $$('table.stripped tr:nth-child(odd)').invoke("addClassName", "oddRow");
});

Just make sure you add a css style for those odd rows:

table.stripped tr.oddRow { background-color: #CCCCCC; }

No Comment.

Add Your Comment