<!DOCTYPE html>
<html>
<head>
<style>
.mystyle {
width: 300px;
height: 50px;
background-color: coral;
color: white;
font-size: 25px;
}
.newClassName {
width: 400px;
height: 100px;
background-color: lightblue;
text-align: center;
font-size: 25px;
color: navy;
margin-bottom: 10px;
}
</style>
</head>
<body>
<p>Click the button to toggle between two classes.</p>
<button onclick="myFunction()">Try it</button>
<p><strong>Note:</strong> The classList property is not supported in Internet Explorer 9 and earlier versions.</p>
<div id="myDIV" class="mystyle">
I am a DIV element
</div>
<script>
function myFunction() {
document.getElementById("myDIV").classList.toggle("newClassName");
}
</script>
</body>
</html>