Updated addClassIf to include optional "else" class name.