Splintered striper

Enhanced zebra stripes

Track Name Artist
1 (Can't You) Trip Like I Do Filter & Crystal Method
2 Poison The Prodigy
3 Better Things Massive Attack
4 Meatplow Stone Temple Pilots
5 Superunknown Soundgarden
6 Bug Powder Dust Bomb The Bass
7 Papua New Guinea The Future Sound of London
8 Straight Outta Compton N.W.A.
9 Socio-Genetic Experiment Disposable Heroes of Hiphoprisy
10 America - What Time is Love The K.L.F.

striper('tbody','striped','tr','odd,even');

The classic "zebra stripes" example: two alternating classes added to each table row. As the new function is very generic, it does not distinguish between thead and tbody when applied to an entire table. That's why here we apply the function to the tbody element, which has been assigned a class of striped (so that, if there were any other tables in the document, they would not be affected). Also note that some rows already have a class of selected assigned to them in the HTML; this class is retained even after the function has taken effect, with the odd and even classes being added to any current class assignment. The CSS contains a compound style to visually stripe odd and even selected rows as well by changing the foreground colour (this last effect does not work in IE in this particular instance, due to the use of the multiple class selector).

Artists on the tracklist

striper('ul','striped','li','first,second,third');

Here we applied the more generic function to an unordered list, assigning three alternating classes. Again, to target this list, we also use a class on the ul element.

Style all headings

striper('body',null,'h2','h_odd,h_even');

To show how the function can be used in a very general way, it has also been applied to all of the document's h2 headings by setting the parentElementTag to body and leaving the optional parentElementClass set to null.