Applying Even/Odd Classes

Submitted by:Jhon Smith

Date added:30 January, 2011


Applying Even/Odd Classes

Tags: even class , php class , apply class

Code Snippet:

<div class="example-class<?php echo ($xyz++%2); ?>">

/*Used inside a loop, class names would be named .example-class0 and .example-class1 alternating. Increasing the "2" number allows you to increment in thirds or fourths or whatever you need:*/

class="class<?php echo ($xyz++%3); ?>"

/*Classes: class0 class1 class2 class0 class1 class2

Change number to 4, this is the result: class0 class1 class2 class3 class0 class1 class2 class3*/