Trying to make a class switcher that will do the following:
- On Load – randomly select one of 10 classes to add to an element
- While Hovering – Rapidly (every 0.4s) switch between 10 classes
- On mouseOut – leave the current class active
I’ve tried several ways of doing this, none of which have worked.
What do you think would be the best way to do this?
Here’s a different implementation that works in your jsFiddle here: http://jsfiddle.net/jfriend00/b7A4a/. This one also makes sure that the randomly generated class name is different than the previous one so the color actually changes every 400ms rather than skipping a change 1 out of 10 times because it generates the same color value that it just had.