Image useMap Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Image


The useMap property sets or gets the usemap attribute of an image, which identifies if an image is used as a client-side image-map.

Set the useMap property with the following Values

#mapname A hash character ("#") plus the name of the map element

Return Value

A String, representing the value of the usemap attribute of the image, including the hash character ("#")

The following code shows how to Set the useMap property:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<img id="planets" src="" width="145" height="126">

<map name="myMap">
  <area id="myId" shape="circle" coords="125,60,10" alt="alt message" href="">
</map>/*w ww  .  j  a  v a2s. c o  m*/

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

<button onclick="myFunction()">Test</button>

function myFunction() {
    var x = document.getElementById("planets").useMap = "#myMap";
    document.getElementById("demo").innerHTML = "The usemap is set!";


Related Tutorials