Instead of doing it in 2 steps, you could just reset the entire value at once with attr
by overwriting all of the class values with the class you want:
jQuery('#container div.cleanstate').attr('class', 'cleanstate');
Sample: http://jsfiddle.net/jtmKK/1/