Add or remove classes from a DOM element