Change the alternate text for a specific area in an image-map:
document.getElementById("myArea").alt = "my target";
Click the button to change the alternate text of the myArea
area in the image-map.
<!DOCTYPE html> <html> <body> <img src="image1.png" width="100" height="100" usemap="#myFlagMap"> <map name="myFlagMap"> <area id="myArea" shape="circle" coords="50,50,40" alt="alt message" href="https://www.java2s.com"> </map>/*from w w w . j a v a2 s.com*/ <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myArea").alt = "my target"; document.getElementById("demo").innerHTML = "The value of the alt attribute was changed."; } </script> </body> </html>