Code Snippets Gallery
Applying Even/Odd Classes
<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
FYI, the 2nd example should read:
class="class"doh:
class="class\"ok I give up. Just add 3 instead of 2 :P
Easiest method I have ever seen, thank you!
That was easy!
Thanks~!
Wow. That rocks! Thank you so much!
thanku :) heaps :)