DomTokenList.add
is used to add more tokens to a list such as adding a class to an element. It can help stylize webpages with the use of css classes.
<body>
<div>
<h1>
Nothing
</h1>
<br>
<button onclick="change()">
change
</button>
</div>
</body>
body {
display: flex;
align-items: center;
justify-content: center;
}
.something {
background-color: #2F004F;
color: white;
font-style: italic;
}
function change() {
document.body.classList.add('something');
}