<!DOCTYPE html>
<html>
<style>
.myStyle {
background-color: coral;
padding: 16px;
}
.newStyle {
background-color: lightblue;
text-align: center;
font-size: 25px;
padding: 16px;
}
</style>
<body>
<h1>The Element Object</h1>
<h2>The className Property</h2>
<button onclick="myFunction()">Toggle</button>
<p>Click "Toggle" (many times) to toggle between two classes.</p>
<div id="myDIV" class="myStyle">
<p>I am myDIV.</p>
</div>
<script>
function myFunction() {
const element = document.getElementById("myDIV");
if (element.className == "myStyle") {
element.className = "newStyle";
} else {
element.className = "myStyle";
}
}
</script>
</body>
</html>