A Simple Color Alternation Script For Lists
Published April 18th, 2006 under JavaScript, Web Development
by Mashhoor Al Dubayan
Here’s an example for a script i’ve made today to set ‘odd’ and ‘even’ class names for each <li> element in a list(s). The source code should be self-explanatory, so i guess no explanation is needed here.
Your script doesn’t really seem to work, or if you made a Javascript, you forgot to include the script.
Fixed. Thanks for pointing that out.
Actually it WAS linked properly, but it seems like Internet Explorer didn’t support the method i’ve used (Firefox and Opera did). It should work now (refresh if it doesn’t).
That loop can be cleaned up a little with less code repetition. Here’s how I would do it
for(var i=0; i
hmmm….my comment was eaten
Again, all in one line:
for(var i=0; iIt’s the < that’s killing it, Vinnie. :p
Yeah I realized that, I just emailed the code instead
Thanks Vinnie. I should’ve thought of the ternary operator.