To replace an existing class with a new one, use the jQuery. removeClass() function to remove the old one and the jQuery. addClass() method to add the new one.