Javascript examples for DOM HTML Element:Area
The alt property sets or gets the value of the alt attribute of an area.
The alt attribute sets an alternate text for an area, if the image cannot be displayed.
Set the alt property with the following Values
Value | Description |
---|---|
text | The alternate text for the area |
A String, representing an alternate text for the area
The following code shows how to Get the alternate text of a specific area in an image-map:
<!DOCTYPE html> <html> <body> <img src="http://java2s.com/resources/a.png" width="145" height="126" usemap="#myMap"> <map name="myMap"> <area id="myId" shape="circle" coords="125,60,10" alt="alt message" href="venus.htm"> </map>/*w w w . j av a 2 s. c o m*/ <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var v = document.getElementById("myId").alt; document.getElementById("demo").innerHTML = v; } </script> </body> </html>