I found the following regex from another Stack Overflow question: Change an element's class with JavaScript
And have used it in part of my script with success, h
foo.className = foo.className.replace( /(?:^|\s)bar(?!\S)/ , '' );
or with jQuery (which you seem to be using):
foo.removeClass( 'bar' );