This is a bad practice. A CSS class should have a single definition. Modifying the class conditionally makes your code hard to follow and hard to maintain.
The correct way would to be create a separate CSS class for each condition, or modify the DOM directly using Javascript.