<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>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_namednodemap_item4 by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 03:01:38 GMT -->
</html>