JavaScript 2025 · DOM and browser

Add, remove or toggle a class

Change CSS classes on an element.

element.classList.toggle("active");

Official JavaScript 2025 documentation

More dom and browser commands

All dom and browser commands · JavaScript 2025 cheatsheet

Was this page helpful?