Published in: JavaScript
Uses jQuery to add a class to odd table rows, for purposes of alternating colors, etc.
$("tr:nth-child(odd)").addClass("odd");
Comments
Subscribe to comments
You need to login to post a comment.
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.
breakerjump on 07/27/08
jquery rows odd even Alternating
1 person has marked this snippet as a favorite
Published in: JavaScript
Uses jQuery to add a class to odd table rows, for purposes of alternating colors, etc.
$("tr:nth-child(odd)").addClass("odd");
Subscribe to comments
You need to login to post a comment.
or do it this way: $('tr:odd').addClass('odd'); $('tr:even').addClass('even');