![Add, remove, toggle, and check for the presence of a class.](https://javascriptsource.com/wp-content/uploads/2021/10/Add-remove-toggle-and-check-for-the-presence-of-a-class-702x526.jpg)
Here are some handy, simple ways to manipulate CSS classes.
var elem = document.querySelector('#sandwich');
// Add a class
elem.classList.add('turkey');
// Remove a class
elem.classList.remove('tuna');
// Toggle a class
// (Add the class if it's not already on the element, remove it if it is.)
elem.classList.toggle('tomato');
// Check if an element has a specific class
if (elem.classList.contains('mayo')) {
console.log('add mayo!');
}