Source Code: (back to article)
<!DOCTYPE html>
<html>
<head>
<style>
.style {
width: 150px;
height: 50px;
background-color:#1c87c9;
text-align: center;
font-size: 20px;
Color: #e6ebef;
margin-bottom: 10px;
padding: 5px;
}
</style>
</head>
<body>
<p>Klicken Sie auf den Button, um class für das Tag div einzustellen.</p>
<div id="Div">
Ich bin ein Div Element.
</div>
<button onclick="myFunction()">Klicken</button>
<script>
function myFunction() {
document.getElementById("Div").className = "style";
}
</script>
</body>
</html>