Recipe 17.5

Conditionally Setting a CSS Class

Code

JavaScript
element.classList.toggle('expanded', isExpanded);
Web API Cookbook
Joe Attardi