I had a little JS problem which I thought I’d solve as a plugin.

This plugin provides functionality similar to jQuery’s built in toggleClass() function, but instead of adding/removing a single class from an element, switchClass toggles between TWO classes ensuring that one and only one of the two classes is assigned to an element (or elements) at one time. It leaves all other element classes untouched and only affects the two classes specified.

See demo and download script here.