<!DOCTYPE html>
<html>
<head>
<style>
.class1 {
width: 200px;
height: 50px;
background-color: #1c87c9;
color: #e6ebef;
font-size: 25px;
padding: 5px;
}
</style>
</head>
<body>
<p>Cliquez sur le bouton pour ajouter une "class1" catégorie à Div.</p>
<button onclick="myFunction()">Click</button>
<p><strong>Note:</strong> La propriété classList n’est pas supporté en Internet Explorer 9 et les versions antérieures.</p>
<div id="myDiv">
Je suis un élément DIV.
</div>
<script>
function myFunction() {
document.getElementById("myDiv").classList.add("class1");
}
</script>
</body>
</html>