Code Snippet
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 :)
It´s very Good
Awesome,
The easiest one so far. So we do not have to use the old
one…. Saves time :)
what about this technique, i think its much faster then taking decision on if statement.
$class = ($class==’class1′) ? “class2″ : “class1″ ;
DigWP
A book and blog co-authored by Jeff Starr and myself about the World's most popular publishing platform.
Quotes on Design
Design, like Art, can be an elusive word to define and an awfully fun thing to have opinions about.
HTML-Ipsum
One-click copy to clipboard access to Lorem Ipsum text that comes wrapped in a variety of HTML.
Bookshelf
Hey Chris, what books do you recommend? These, young fertile mind, these.