here's something i put together var iseven = 0; // a normal 1, 0 switch var limit = 34; // maximum limit
$("body").prepend('<ul class="test"><\/ul>'); // i want to do this as a list for(var i = 0; i < limit; i++) { if(iseven = 0) { // if odd $(".test").append('<li class="odd">Odd<\/li>') iseven = 1; } else { // if even $(".test").append('<li class="even">Odd<\/li>') iseven = 0 } } /* ========== OUTPUT ======= <ul class="test"> <li class="odd">Odd</li> <li class="even">Even</li> .... .... </ul> */ this way you create even and odd list items. may be you can manipulate this logic to achieve what you need. On Sat, Jun 6, 2009 at 3:57 PM, RobG <robg...@gmail.com> wrote: > > > > On Jun 6, 11:25 pm, Karl Swedberg <k...@englishrules.com> wrote: > > You can make that first line a bit more compact: > > > > $("li").removeClass("even odd") > > It's still very inefficient. All that is required is for the LIs > below the deleted one to have their class swapped from odd to even and > vice versa. > > > -- > Rob >