Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<style>
.example {
  color: red;
  width: 150px;
  font-size: 20px;
}
</style>
<body>
<h1>HTML DOM Attributes</h1>
<h2>The length Property</h2>
<button id="myBtn" onclick="myFunction()" class="example">Try it</button>
<p>The attributes of the button above is:</p>
<p id="demo"></p>
<script>
let text = "";
const nodeMap = document.getElementById("myBtn").attributes;
for (let i = 0; i < nodeMap.length; i++) {
  text += nodeMap[i].name + "<br>";
}
document.getElementById("demo").innerHTML = text;
function myFunction() {}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_namednodemap_length2 by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 21 Dec 2022 17:39:46 GMT -->
</html>