+8  A: 

If I get you right, you might just want to use .toggleClass().

$('#obj').click(function() {
    $(this).toggleClass('foo bar');
});

Ref.: .toggleClass()

Example: http://www.jsfiddle.net/sTBcb/

jAndy
That's brilliant! I hadn't thought of doing it that way.
aem
That is exactly what I was looking for. I've tried `toggleClass` before, but did not know you can do it this way, even after reading the docs, +1! So anything that's currently in the class is replaced by anything in the list: `class="a foo z baz"` and the toggle was `"foo bar foobar baz"`, then the new class would be `class="a z bar foobar"`; good to know. The one thing I'm worried about is the order of the class listing - both switchClass and toggleClass seem to append to the end, rather than replace the actual order.
vol7ron