We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


Posted By

breakerjump on 07/27/08


Tagged

jquery rows odd even Alternating


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

jonhenshaw


Alternating Table Rows via jQuery


Published in: JavaScript 


Uses jQuery to add a class to odd table rows, for purposes of alternating colors, etc.

  1. $("tr:nth-child(odd)").addClass("odd");

Report this snippet 

Comments

RSS Icon Subscribe to comments
Posted By: NeoBlack on July 27, 2008

or do it this way: $('tr:odd').addClass('odd'); $('tr:even').addClass('even');

You need to login to post a comment.