Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<h1>HTML DOM Attributes</h1>
<h2>The length Property</h2>
<img id="myImg" alt="Flower" src="klematis.jpg" width="150" height="113">
<p>The attributes of the image are:</p>
<p id="demo"></p>
<script>
const nodeMap = document.getElementById("myImg").attributes;
let text = "";
for (let i = 0; i < nodeMap.length; i++) {
  text += nodeMap[i].name + " = " + nodeMap[i].value + "<br>";
}
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>