DOM

Element.classList

Learn how to use Element.classList in JavaScript.

Element.classList

Documentation for Element.classList in JavaScript.

Syntax

el.classList.add("active")

Example

// Practical usage
el.classList.add("active")
console.log("Executed successfully.");

Notes

JavaScript provides powerful built-in methods for the web.

Try It Yourself

You can run JavaScript directly in the BrowserCode Playground.