JSFiddle - React, Tailwind, and code Playground
by Stephen
HTML
<div id="aRandomDivforThisQuestion">
<a href="#">a red link</a>
<p>
<a href="#">a green link</a>
<a href="#">a red link again</a>
</p>
<a href="#">yet again a green link</a>
<div>
<a href="#">still another red</a><br/>
<a href="#">finally a last green</a>
</div>
</div><!-- /aRandomDivForThisQuestion -->
CSS
a { text-decoration: none; }
a.even { color: green; }
a.odd { color: red; }
a.bld { font-weight: bold; }
a.ital { font-style: italic; }
a.undrln { text-decoration: underline; }
JavaScript
function stripe(elems, classes)
{
var which = 0;
$(elems).each(function(i, elem) {
var addit = classes[which];
which = (which + 1) % classes.length;
$(elem).addClass(addit);
});
}
stripe( $('#aRandomDivforThisQuestion a'),
[ 'odd', 'even' ] );
stripe( $('#aRandomDivforThisQuestion a'),
[ 'bld', 'ital', 'undrln' ] );