new setClass effect (with use cases)

new setClass effect (with use cases)

Input fields in ajax forms often have multiple visual states, usually stored in css classes such as .default, .invalid, .modified, etc.

I could not find an easy way to animate those input fields from their current state to any new class. addClassdoes not remove the current classes. switchClass requires knowledge of the other classes (introducing code duplication). Doing $(elem).attr('class','').addClass('myClass'); transitions from the default style rather than from the current style.

With the patch you can do : $(elem).setClass('myClass','slow');

Let me know if I missed a simple way to do that.

Note: I have submitted this to Trac as well. Which one is the best for patch proposals?