jQuery: Cycling between multiple classes with random start

A directed graph.
Image via Wikipedia

I saw an interesting question on StackOverflow on how to cycle between 3 states for list items , but with initial state for each item being potentially different.

This random start position part of the problem was making me think, so I used it as an exercise to try some newish jQuery functions, such as delegate and advanced class selectors.

My solution was basically to build a reduced case of state transition diagram with a cycle.  The advantage of it is that any number of states can be iterated through.  It  could even be a plugin, if need be.

My full test example can be found in the original SO question, probably toward the bottom. I am also including it here as a Pastie:

Enhanced by Zemanta

2 thoughts on “jQuery: Cycling between multiple classes with random start”

  1. I don’t use it much. I find it flows too fast for me to track/contribute. On the other hand, I usually answer my own questions. But it is a good resource.

    On the other hand, I am not too hot on Joel. I just finished listing to Jeff’s rant on Herding Code from back in July and I learned more about Stack Overflow and thinking behind it on it than from all the hours of listening to them together on Stack Overflow’s own podcast.

    But Joel does (did) have interesting articles.

Comments are closed.