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

HTMLJavascriptProgramming Scripts

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>
raja
Updated on 23-Jun-2020 11:03:29

Advertisements