we could even extend this, to a mini plugin (function($) {
$.fn.jqStripeMe = function(options) { // Set up default options var defaults = { defaultClass : 'odd', altClass : 'even', zebraGroup : 2 }; // Extend our default options with those provided. var opts = $.extend(defaults, options); var $this = $(this); $("tr", $this).each(function(i){ var x= parseInt(i/opts.zebraGroup)%2; if (x==1) $(this).addClass(opts.defaultClass); else $(this).addClass(opts.altClass); return this; }); }; })(jQuery); useage: $('#myTable').jqStripeMe({ defaultClass : 'boo', altClass : 'hoo', zebraGroup:1 <<<<----- alternate row striping.............. or zebraGroup:3 <<<<<--- blocks of three rows }); On 25/03/2008, Giuliano Marcangelo <[EMAIL PROTECTED]> wrote: > > > $(function() { > $(".stripeMe tr").each(function(i){ > var x= parseInt(i/3)%2; > if (x==1) > $(this).addClass('odd'); > else > $(this).addClass('even'); > }); > }); > there must be easier ways, but this works fine > > :-) > > On 25/03/2008, Leandro Vieira Pinho <[EMAIL PROTECTED]> wrote: > > > > > > Hi guys, > > > > I´m looking for a solution to apply a Zebra Table Effect considering 3 > > rows a time instead 1. For example: > > > > It´s my table. > > > > row 1 > > row 2 > > row 3 > > row 4 > > row 5 > > row 6 > > row 7 > > row 8 > > row 9 > > > > Each 3 rows is related to a subject. So in each 3 rows I want applay a > > diffrent colour. To get something like it: > > > > row 1 - apply class to change bg > > row 2 - apply class to change bg > > row 3 - apply class to change bg > > row 4 > > row 5 > > row 6 > > row 7 - apply class to change bg > > row 8 - apply class to change bg > > row 9 - apply class to change bg > > > > Some suggestions? > > > > Regardsds > > > >