<!DOCTYPE html>
<html>
<head>
<style>
.example {
color: red;
padding: 5px;
width: 150px;
font-size: 15px;
}
.newClass {
color: blue;
padding: 15px;
width: 250px;
font-size: 18px;
background-color: white;
}
</style>
</head>
<body>
<p>Click the button to change the value of the button element's second attribute.</p>
<button onclick="myFunction()" class="example">Try it</button>
<script>
function myFunction() {
var a = document.getElementsByTagName("BUTTON")[0];
a.attributes[1].value = "newClass";
}
</script>
</body>
</html>