<!DOCTYPE html>
<html lang="en-US">
<body>
<p>Click on the button to get the number of attributes used in button tag.</p>
<button onclick="myFunction()">Click Me</button>
<p id="point"></p>
<script>
var x = document.getElementById("point");
var elem = document.getElementsByTagName("button")[0];
function myFunction(){
x.innerHTML = elem.attributes.length;
}
</script> </body>
</html>