<h1 id="myH1">The Element Object</h1>
<h2>The setAttribute() Method</h2>
<p>Click "Add Class" to add a class attribute to the h1 element:</p>
<button onclick="myFunction()">Add Class</button>
.warna{
color: red;
}
function myFunction() {
document.getElementById("myH1").setAttribute("class", "warna");
}
HTML
CSS
JS