Add striping (odd even classes) in jQuery - stripe
/*
* Add striping
*
*/
function stripe(el){
var count = 0;
$(el).each(function(){
count++;
var classEven = '';
var classOdd = '';
var classThird = '';
var classFourth = '';
if(0 == count%2){
classEven='even';
$(this).addClass(classEven);
}
if(1 == count%2){
classOdd='odd';
$(this).addClass(classOdd);
}
if(0 == count%3 && false == $(this).hasClass('first')){
classThird='third';
$(this).addClass(classThird);
}
if(0 == count%4 && false == $(this).hasClass('first')){
classFourth='fourth';
$(this).addClass(classFourth);
}
});
};
// use example
// stripe secondary-menu
stripe('.secondary-menu > ul li');