I am currently using this code to add a class to every other row in my table.
$(".stripeMe tr:even").addClass("alt");
However, on another table I'd like to add a class to rows 3,4, 7,8, 11,12 and so on...
Is this possible?
You need to do it like this:
$(".stripeMe tr:nth-child(4n)").add(".stripeMe tr:nth-child(4n-1)").addClass("alt");
//or...
$("tr:nth-child(4n), tr:nth-child(4n-1)", ".stripeMe").addClass("alt");
You can see this working here.
Using this:
$(".stripeMe tr:nth-child(4n), .stripeMe tr:nth-child(4n-1)").addClass("alt");
gets different results (namely in webkit, possibly others).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With