Source Code: (back to article)
<div id="addClassExample">This element will have classes added.</div>
<button onclick="addClass()">Add Class</button>

<script>
function addClass() {
const element = document.getElementById('addClassExample');
element.classList.add('highlight', 'text-large');
}
</script>

<style>
.highlight {
background-color: yellow;
}

.text-large {
font-size: 24px;
}
</style>