Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<h1>HTML DOM Attributes</h1>
<h2>The name Property</h2>
<div id="myDiv" style="background-color:red;width:50px;height:50px"></div>
<p id="demo"></p>
<script>
const nodeMap = document.getElementById("myDiv").attributes;
let name1 = nodeMap[0].name;  
let name2 = nodeMap[1].name;
  
document.getElementById("demo").innerHTML =
"First attribute is: " + name1 +
"<br>Second is: " + name2;
</script>
</body>
</html>