Map name Property - Change the name of an image-map: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Map

Description

Map name Property - Change the name of an image-map:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<img src="http://java2s.com/resources/a.png" width="145" height="126" alt="alt message" usemap="#myMap">

<map id="myMap" name="myMap">
  <area shape="rect" coords="0,0,82,126" alt="rect" href="http://java2s.com">
  <area shape="circle" coords="90,60,5" alt="circle1" href="http://java2s.com">
  <area shape="circle" coords="125,60,10" alt="circle2" href="http://java2s.com">
</map>//from  w ww. j  a v  a2  s  . com

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

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

<script>
function myFunction() {
    document.getElementById("myMap").name = "newMapName";
    document.getElementById("demo").innerHTML = "changed";
}
</script>

</body>
</html>

Related Tutorials