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
Value | Description |
---|---|
#mapname | A hash character ("#") plus the name of the map element |
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:
<!DOCTYPE html> <html> <body> <img id="planets" src="http://java2s.com/resources/a.png" width="145" height="126"> <map name="myMap"> <area id="myId" shape="circle" coords="125,60,10" alt="alt message" href="http://java2s.com"> </map>/*w ww . j a v a2s. c o m*/ <p id="demo"></p> <button onclick="myFunction()">Test</button> <script> function myFunction() { var x = document.getElementById("planets").useMap = "#myMap"; document.getElementById("demo").innerHTML = "The usemap is set!"; } </script> </body> </html>