How to replace class

How to replace class, let say I want to replace class A to be class B and then after a few seconds replace class B to be class A

Please read the docs. It covers all of this.