<!DOCTYPE html>
<html>
<head>
<style>
.example {
    color: red;
    padding: 5px;
    width: 150px;
    font-size: 15px;
}

</style>
</head>
<body>

<p>Click the button to get all attribute names of the button element.</p>

<button id="myBtn" onclick="myFunction()" class="example">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
    var txt = "";
    var x = document.getElementById("myBtn").attributes;

    var i;
    for (i = 0; i < x.length; i++) {
        txt += "Attribute name: " + x[i].name + "<br>";
    }
    document.getElementById("demo").innerHTML = txt;
}
</script>

</body>
</html>