<html>
<head>
<style>
.mystyle {
width: 500px;
height: 50px;
border: 1px solid black;
margin-bottom: 10px;
}
.anotherClass {
background-color: coral;
text-align: center;
font-size: 25px;
color: white;
}
</style>
</head>
<body>
<p>Click the button to add an additional class to the div element.</p>
<div id="myDIV" class="mystyle">
I am a DIV element
</div>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
document.getElementById("myDIV").className += " anotherClass";
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_element_classname5 by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 05 Jun 2019 14:03:51 GMT -->
</html>