Open In App

How to add a class to DOM element in JavaScript?

DOM (Document Object Model) is a way of manipulating the document (HTML document). This article will deal with how to access and set class names to the DOM elements. In DOM, all HTML elements are defined as objects. We will be using Javascript against CSS to manipulate them.

Following are the properties of Javascript that we will be using to add a class to the DOM element:



Supported Browsers: The browser supported by classList property are listed below:


Article Tags :