Change CSS Class of Div Tag

JavaScript Change CSS Class of Div tag functionality can be developed by using JavaScript DOM ClassName property. In this sample ClassName property of the object returned by getElementById method of JavaScript DOM has been used to change the CSS Class of HTML Div element dynamically.

JavaScript DOM Features Used

1. document object

2. getElementById method

3. ClassName property

Try the sample below to learn and practice the JavaScript DOM code for developing this functionality:

Edit this code and click update to view output
OUTPUT: