Javascript DOM HTML Image useMap Property get

Introduction

Return the value of the usemap attribute of an image:

var x = document.getElementById("planets").useMap;

Click the button to display the value of the usemap attribute of the image.

View in separate window

<!DOCTYPE html>
<html>
<body>

<img id="planets" src="image1.png" width="100" height="100" usemap="#myFlagMap">

<map name="myFlagMap">
  <area id="myArea" 
        shape="circle" 
        coords="50,50,40" 
        alt="The Circle" 
        href="https://www.java2s.com">
</map>//from   w w w .  j a  va2 s  .c  om
<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {
  var x = document.getElementById("planets").useMap;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related