How to get the value of the usemap attribute of an image with JavaScript?


To get the value of the usemap attribute of an image, use the useMap property. You can try to run the following code to display the usemap attribute value −

Example

<!DOCTYPE html>
<html>
   <body>
      <img id = "myid" src = "/images/html.gif" alt = "HTML Map" usemap = "#html"/>
      <map name = "html">
         <area id = "myarea" shape = "circle" coords = "154,150,59" href = "about.htm" alt = "Team" >
      </map>
      <script>
         var x = document.getElementById("myid").useMap;
         document.write("<br>Usemap: "+x);
      </script>
   </body>
</html>

Updated on: 23-Jun-2020

105 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements